Merge branch 'develop' of https://git.pthub.vn/Unity/perfect-world-unity into develop
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2035,10 +2035,9 @@ namespace CSNetwork
|
||||
string strSrcName = Encoding.Unicode.GetString(p.Name.ToArray());
|
||||
|
||||
string fmt = AUICommon.ConvertPrintfToCSharpFormat(pStrTab.GetWideString((int)FixedMsg.FIXMSG_CHAT));
|
||||
string nameWithTag = $"&{strSrcName}&";
|
||||
string formatted;
|
||||
try {
|
||||
formatted = string.Format(fmt, nameWithTag, strMsg);
|
||||
formatted = string.Format(fmt, strSrcName, strMsg);
|
||||
} catch {
|
||||
formatted = $"{strSrcName}: {strMsg}";
|
||||
}
|
||||
@@ -2262,12 +2261,9 @@ namespace CSNetwork
|
||||
// Format: "[Name] whispers to [You]: [Message]"
|
||||
string fmt = AUICommon.ConvertPrintfToCSharpFormat(pStrTab.GetWideString((int)FixedMsg.FIXMSG_PRIVATECHAT1));
|
||||
|
||||
// Wrap sender name in & so the AddChatMessage regex can color it.
|
||||
string nameWithTag = $"&{strSrcName}&";
|
||||
|
||||
string formatted;
|
||||
try {
|
||||
formatted = string.Format(fmt, nameWithTag, strMsg);
|
||||
formatted = string.Format(fmt, strSrcName, strMsg);
|
||||
} catch {
|
||||
formatted = $"{strSrcName} whispers to you: {strMsg}";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -41,18 +41,18 @@ namespace BrewMonster.UI
|
||||
// true = show male, false = show female
|
||||
private static readonly bool[] s_bShowMale = new bool[]
|
||||
{
|
||||
true, // 0: Warrior (武侠)
|
||||
false, // 1: Mage (法师)
|
||||
false, // 2: Priest (巫师)
|
||||
false, // 3: Assassin (妖精)
|
||||
true, // 4: Orc (妖兽)
|
||||
true, // 5: Monk (刺客)
|
||||
true, // 6: Elf (羽芒)
|
||||
false, // 7: Elf (羽灵)
|
||||
true, // 8: Ling (剑灵)
|
||||
false, // 9: Ling (魅灵)
|
||||
true, // 10: Oboro (夜影)
|
||||
false, // 11: Oboro (月仙)
|
||||
true, // 0: kiem khach (nhan toc)
|
||||
false, // 1: phap su (nhan toc)
|
||||
false, // 2: vu su (tich toc)
|
||||
false, // 3: tien thu (thu toc)
|
||||
true, // 4: than thu (thu toc)
|
||||
true, // 5: thich khach (tich toc)
|
||||
true, // 6: vu mang (vu toc)
|
||||
false, // 7: vu linh (vu toc)
|
||||
true, // 8: kiem linh (linh toc)
|
||||
false, // 9: mi linh (linh toc)
|
||||
true, // 10: da anh (long toc)
|
||||
false, // 11: nguyet tien (long toc)
|
||||
};
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user