From 4bce9e7fb2ed9f51382af77b9a418cf125fadb67 Mon Sep 17 00:00:00 2001 From: CuongNV <> Date: Tue, 31 Mar 2026 17:14:13 +0700 Subject: [PATCH] update code change color --- .../Scripts/Chat/UI/ChatMessageView.cs | 5 +- .../Scripts/UI/Dialogs/AUIDialog.cs | 2 +- .../ChatSystem/prefab_TextContents.prefab | 4 +- Assets/Scripts/EC_GameRunChat.cs | 62 ++++++++++--------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs b/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs index 7149875ed4..c83e5943df 100644 --- a/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs +++ b/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs @@ -1,4 +1,5 @@ using BrewMonster.Scripts.Task.UI; +using BrewMonster.Scripts.UI; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -8,7 +9,7 @@ namespace BrewMonster.Scripts.ChatUI public class ChatMessageView : MonoBehaviour { public Image iconImage; - public TextMeshProUGUI messageText; + public EC_UIUtility.TextOutlet messageText; public void Bind(Sprite iconSprite, string message) { @@ -20,7 +21,7 @@ namespace BrewMonster.Scripts.ChatUI iconImage.sprite = iconSprite; iconImage.enabled = iconSprite != null; - messageText.text = message; + messageText.Set(message); GetComponent().RefreshLayout(); } } diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs index 2490475da9..c7eaea806e 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/AUIDialog.cs @@ -117,7 +117,7 @@ namespace BrewMonster.UI /// Convert/format printf-style strings (e.g. "ID:%d Name:%s") with C# args. /// Supports common specifiers and keeps "%%" as a literal percent. /// - protected static string FormatPrintf(string formatStr, params object[] args) + public static string FormatPrintf(string formatStr, params object[] args) { if (string.IsNullOrEmpty(formatStr)) return formatStr; diff --git a/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab b/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab index 4a8a8040a8..97f2d74f02 100644 --- a/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab +++ b/Assets/Prefabs/ChatSystem/prefab_TextContents.prefab @@ -330,7 +330,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: iconImage: {fileID: 2098686458651577804} - messageText: {fileID: 5305392080666511277} + messageText: + legacy: {fileID: 0} + tmp: {fileID: 5305392080666511277} --- !u!114 &-887576589064363463 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/EC_GameRunChat.cs b/Assets/Scripts/EC_GameRunChat.cs index f49fe87bca..5ba9947eaf 100644 --- a/Assets/Scripts/EC_GameRunChat.cs +++ b/Assets/Scripts/EC_GameRunChat.cs @@ -3,6 +3,7 @@ using System.Net; using CSNetwork; using CSNetwork.GPDataType; using BrewMonster.Common; +using BrewMonster.UI; using UnityEngine; // Account login info struct @@ -42,44 +43,49 @@ partial class CECGameRun public void ShowAccountLoginInfo() { Debug.Log("[Cuong] ShowAccountLoginInfo"); - + // Kiểm tra cờ xem đã hiển thị thông tin đăng nhập chưa để tránh in lặp lại nhiều lần. if (!m_bAccountLoginInfoShown) { - m_bAccountLoginInfoShown = true; - - // (Trong C++ gốc: CECUIConfig::Instance().GetGameUI().bEnableShowIP) - // Hiện tại mặc định bật cờ hiển thị IP đăng nhập. - bool bEnableShowIP = true; - if (bEnableShowIP) + var pGameUI = CECUIManager.Instance?.GetInGameUIMan(); + if (pGameUI != null) { - // 1. Tính toán và hiển thị thời gian đăng nhập lần trước (Last login time). - // Hàm này cộng dồn số giây cấu hình được từ server so với mốc Epoch (1/1/1970) sang Local time. - DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - DateTime t = Epoch.AddSeconds(m_AccountLoginInfo.login_time).ToLocalTime(); + m_bAccountLoginInfoShown = true; - string timeStr = string.Format("({0}-{1:00}-{2:00} {3:00}:{4:00})", - t.Year, t.Month, t.Day, t.Hour, t.Minute); - string textTime = string.Format("Lần đăng nhập trước: {0}", timeStr); // Tương đương mảng TextTable ID 9343 + // (Trong C++ gốc: CECUIConfig::Instance().GetGameUI().bEnableShowIP) + // Hiện tại mặc định bật cờ hiển thị IP đăng nhập. + bool bEnableShowIP = true; + if (bEnableShowIP) + { + // 1. Tính toán và hiển thị thời gian đăng nhập lần trước (Last login time). + DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + DateTime t = epoch.AddSeconds(m_AccountLoginInfo.login_time).ToLocalTime(); - // Phát sinh sự kiện để hệ thống Chat in log vào kênh SYSTEM. - EventBus.Publish(new GameSession.ChatMessageEvent { context = textTime, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); - Debug.Log($"[Cuong] ShowAccountLoginInfo {textTime}"); + // Table 8010: chuỗi dạng "%d-%d-%d %d:%d" hoặc tương tự + string timeStr = AUIDialog.FormatPrintf(pGameUI.GetStringFromTable(8010), + t.Year, t.Month, t.Day, t.Hour, t.Minute); + // Table 9343: chuỗi dạng "Thời gian đăng nhập trước: %s" + string textTime = AUIDialog.FormatPrintf(pGameUI.GetStringFromTable(9343), timeStr); - // 2. Định dạng và hiển thị IP đăng nhập lần trước (Last login IP). - // Dùng IPAddress parse giá trị số nguyên long ra dạng IPv4 chuẩn. - string ipStr = new IPAddress((long)m_AccountLoginInfo.login_ip).ToString(); - string textIp = string.Format("IP đăng nhập trước: {0}", ipStr); // Tương đương mảng TextTable ID 9344 + EventBus.Publish(new GameSession.ChatMessageEvent { context = textTime, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); + Debug.Log($"[Cuong] ShowAccountLoginInfo {textTime}"); - EventBus.Publish(new GameSession.ChatMessageEvent { context = textIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); - Debug.Log($"[Cuong] ShowAccountLoginInfo {textIp}"); + // 2. Định dạng và hiển thị IP đăng nhập lần trước (Last login IP). + // Table 9344: chuỗi dạng "IP đăng nhập trước: %s" + string ipStr = new IPAddress((long)m_AccountLoginInfo.login_ip).ToString(); + string textIp = AUIDialog.FormatPrintf(pGameUI.GetStringFromTable(9344), ipStr); - // 3. Định dạng và hiển thị IP đăng nhập hiện tại (Current login IP). - string curIpStr = new IPAddress((long)m_AccountLoginInfo.current_ip).ToString(); - string textCurIp = string.Format("IP đăng nhập hiện tại: {0}", curIpStr); // Tương đương mảng TextTable ID 9345 + EventBus.Publish(new GameSession.ChatMessageEvent { context = textIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); + Debug.Log($"[Cuong] ShowAccountLoginInfo {textIp}"); - EventBus.Publish(new GameSession.ChatMessageEvent { context = textCurIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); - Debug.Log($"[Cuong] ShowAccountLoginInfo {textCurIp}"); + // 3. Định dạng và hiển thị IP đăng nhập hiện tại (Current login IP). + // Table 9345: chuỗi dạng "IP đăng nhập hiện tại: %s" + string curIpStr = new IPAddress((long)m_AccountLoginInfo.current_ip).ToString(); + string textCurIp = AUIDialog.FormatPrintf(pGameUI.GetStringFromTable(9345), curIpStr); + + EventBus.Publish(new GameSession.ChatMessageEvent { context = textCurIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM }); + Debug.Log($"[Cuong] ShowAccountLoginInfo {textCurIp}"); + } } } }