diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 8f42f579eb..ee7525407a 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1880,33 +1880,43 @@ namespace CSNetwork p.Msg.Replace(unicodeBytes); SendProtocol(p); - if (cChannel is (byte)ChatChannel.GP_CHAT_LOCAL - or (byte)ChatChannel.GP_CHAT_FARCRY - or (byte)ChatChannel.GP_CHAT_SUPERFARCRY - or (byte)ChatChannel.GP_CHAT_BATTLE - or (byte)ChatChannel.GP_CHAT_COUNTRY) { + // [Port] C++: DlgChat::OnCommand_speak dòng 736: + // Server KHÔNG echo tin nhắn quay lại cho chính người gửi. + // => Phải gọi AddChatMessage ngay tại local để hiển thị lên UI Chat Panel. + { CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); - //int nEmotionSet = pHost.GetCurEmotionSet(); int nEmotionSet = 0; - string strMsg = szMsg; - if (cChannel == (byte)ChatChannel.GP_CHAT_SUPERFARCRY) + + // Head Bubble: Chỉ hiện bong bóng đầu cho các kênh "quanh người" (giống C++ SendChatData) + if (cChannel is (byte)ChatChannel.GP_CHAT_LOCAL + or (byte)ChatChannel.GP_CHAT_FARCRY + or (byte)ChatChannel.GP_CHAT_SUPERFARCRY + or (byte)ChatChannel.GP_CHAT_BATTLE + or (byte)ChatChannel.GP_CHAT_COUNTRY) { - if (strMsg.Length > 8) + string strMsg = szMsg; + if (cChannel == (byte)ChatChannel.GP_CHAT_SUPERFARCRY) { - strMsg = strMsg.Substring(0, strMsg.Length - 8); + if (strMsg.Length > 8) + strMsg = strMsg.Substring(0, strMsg.Length - 8); + nEmotionSet = SUPER_FAR_CRY_EMOTION_SET; } - nEmotionSet = SUPER_FAR_CRY_EMOTION_SET; } - EC_IvtrItem pItem = null; - if (iPack >= 0 && iSlot >= 0) { - EC_Inventory pPack = pHost.GetPack(iPack); - if (pPack != null) { - pItem = pPack.GetItem(iSlot); - } + // UI Chat Panel: Hiển thị cho TẤT CẢ kênh (Local, Team, Faction, Trade...) + CECStringTab pStrTab = EC_Game.GetFixedMsgs(); + string szName = pHost.GetName(); + char[] szText = new char[80]; + AUICommon.AUI_ConvertChatString(ref szName, ref szText, false); + string fmt = AUICommon.ConvertPrintfToCSharpFormat(pStrTab.GetWideString((int)FixedMsg.FIXMSG_CHAT)); + string str; + try { + str = string.Format(fmt, szName, szMsg); + } catch { + str = $"{szName}: {szMsg}"; } - EventBus.PublishChannel(pHost.GetCharacterID(), new EventChatMessageOnTopPlayer(pHost.GetCharacterID(), szMsg)); - EventBus.Publish(new ChatMessageEvent(szMsg, p.Channel)); + EC_Game.GetGameRun().AddChatMessage(str, cChannel, pHost.GetCharacterID(), + null, 0, nEmotionSet, null, szMsg); } } @@ -2670,7 +2680,7 @@ namespace CSNetwork } public void c2s_SendCmdTeamLeaveParty() - { + { var g = new gamedatasend(); g.Data = C2SCommandFactory.CreateTeamLeavePartyCommand(); SendProtocol(g); diff --git a/Assets/Prefabs/ChatSystem/prefab_ChatCanvas.prefab b/Assets/Prefabs/ChatSystem/prefab_ChatCanvas.prefab index 7a5449f04b..e7d9c03282 100644 --- a/Assets/Prefabs/ChatSystem/prefab_ChatCanvas.prefab +++ b/Assets/Prefabs/ChatSystem/prefab_ChatCanvas.prefab @@ -2647,8 +2647,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchoredPosition: {x: 20, y: 0} + m_SizeDelta: {x: -40, y: 0} m_Pivot: {x: 0, y: 1} --- !u!114 &5572451279827723964 MonoBehaviour: diff --git a/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab b/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab index 61d05812aa..767f05e756 100644 --- a/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab +++ b/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab @@ -61,7 +61,7 @@ MonoBehaviour: m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 0 + m_Maskable: 1 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -110,8 +110,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 394, y: -5} - m_SizeDelta: {x: 600, y: 0} + m_AnchoredPosition: {x: 399.5, y: -5} + m_SizeDelta: {x: 601, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!222 &7228077960814023056 CanvasRenderer: @@ -363,7 +363,7 @@ MonoBehaviour: m_Top: 5 m_Bottom: 0 m_ChildAlignment: 0 - m_Spacing: 0 + m_Spacing: 5 m_ChildForceExpandWidth: 0 m_ChildForceExpandHeight: 1 m_ChildControlWidth: 0