update code change color

This commit is contained in:
CuongNV
2026-03-31 17:14:13 +07:00
parent 26257b22a3
commit 4bce9e7fb2
4 changed files with 41 additions and 32 deletions
@@ -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<IRefreshLayout>().RefreshLayout();
}
}
@@ -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.
/// </summary>
protected static string FormatPrintf(string formatStr, params object[] args)
public static string FormatPrintf(string formatStr, params object[] args)
{
if (string.IsNullOrEmpty(formatStr))
return formatStr;
@@ -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
+34 -28
View File
@@ -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}");
}
}
}
}