Merge branch 'develop' of https://git.pthub.vn/Unity/perfect-world-unity into feature/friend_ui

This commit is contained in:
VuNgocHaiC7
2026-03-23 18:00:14 +07:00
10 changed files with 653 additions and 130 deletions
+6 -28
View File
@@ -3,6 +3,7 @@ using BrewMonster.Network;
using BrewMonster.UI;
using System;
using System.Collections.Generic;
using BrewMonster.PerfectWorld.Scripts.Utility.ChatFilter;
using BrewMonster.Scripts.Managers;
using UnityEngine;
using TMPro;
@@ -299,7 +300,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
return null;
}
public CDlgMessageBox ShowMessageBoxYes(string title, string message, AUIDialog dlg, Action onClickedYes)
{
var msgBox = GetInGameUIMan().GetDialog("DlgMessageBox") as CDlgMessageBox;
@@ -336,7 +337,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
return null;
}
// public CDlgMessageBox ShowMessageBox(MessageBoxData messageBoxData)
// {
// var msgBox = GetInGameUIMan().GetDialog("DlgMessageBox") as CDlgMessageBox;
@@ -467,7 +468,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
// g_pGame->GetGameRun()->GetPendingLogOut().AppendForSaveConfig(new CECPendingLogoutCrossServer());
// else
// g_pGame->GetGameRun()->GetPendingLogOut().AppendForSaveConfig(new CECPendingLogoutHalf());
EC_Game.GetGameRun().GetPendingLogOut().AppendForSaveConfig(new CECPendingLogoutHalf());
}
else
@@ -714,7 +715,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
// {
// EC_Game.GetGameRun().StartGame(0, Vector3.zero);
// }
CECShortcut pSC = EC_Game.GetGameRun().GetPoseCmdShortcuts().GetShortcut(slot);
if (pSC != null) // && pObjSrc->GetDataPtr("ptr_CECShortcut") == pSC
{
@@ -775,29 +776,6 @@ public class CECUIManager : MonoSingleton<CECUIManager>
public void FilterBadWords(ref string str)
{
if (string.IsNullOrEmpty(str))
return;
string strLwr = str.ToLower();
char[] chars = str.ToCharArray();
foreach (string bad in gameUI.m_vecBadWords)
{
int pos = 0;
string badLwr = bad.ToLower();
while ((pos = strLwr.IndexOf(badLwr, pos, StringComparison.Ordinal)) >= 0)
{
for (int j = 0; j < badLwr.Length; j++)
{
chars[pos + j] = '*';
}
pos += badLwr.Length;
}
}
str = new string(chars);
str = ChatFilterService.Filter(str, out var isValidWord);
}
}
+40 -12
View File
@@ -23,6 +23,7 @@ namespace BrewMonster.Scripts.ChatUI
public List<ChannelButtonMapping> channelButtons = new();
private const int MAX_HISTORY = 10;
private ChatChannel m_currentChannel = ChatChannel.GP_CHAT_LOCAL;
private struct ChatMsg
{
@@ -57,6 +58,13 @@ namespace BrewMonster.Scripts.ChatUI
{
OnCommand_speakmode(channelButtons[0].channel);
}
// [Mobile Fix] Giữ cho chữ được hiển thị trực tiếp trên UI của game thay vì bị
// đẩy vào một thanh ngang phụ (Native OS Input) bật lên cùng bàn phím.
if (inputField != null)
{
inputField.shouldHideMobileInput = true;
}
}
// =====================================================
@@ -79,13 +87,34 @@ namespace BrewMonster.Scripts.ChatUI
}
}
m_currentChannel = channel;
var config = chatSystem.channelIcons.Find(c => c.channel == channel);
if (config.prefix != null)
{
inputField.text = config.prefix;
inputField.ActivateInputField();
inputField.MoveTextEnd(false);
string currentText = inputField.text;
currentText = RemoveKnownPrefix(currentText);
inputField.text = config.prefix + currentText;
}
inputField.ActivateInputField();
inputField.MoveTextEnd(false);
}
private string RemoveKnownPrefix(string text)
{
if (string.IsNullOrEmpty(text)) return text;
if (text.StartsWith("!!") || text.StartsWith("!~") ||
text.StartsWith("!@") || text.StartsWith("!#"))
{
return text.Substring(2);
}
else if (text.StartsWith("$"))
{
return text.Substring(1);
}
// Không tự ý remove prefix của Whisper (bắt đầu bằng '/') vì nó đi kèm tên người chơi
return text;
}
private void OnSubmit(string text)
@@ -242,8 +271,8 @@ namespace BrewMonster.Scripts.ChatUI
private ChatChannel ParseAndSendMessage(string text, int nPack, int nSlot)
{
ChatChannel channel;
string pszMsg;
ChatChannel channel = m_currentChannel;
string pszMsg = text;
if (text.StartsWith("!!"))
{
@@ -275,11 +304,7 @@ namespace BrewMonster.Scripts.ChatUI
HandleWhisper(text, nPack, nSlot);
return ChatChannel.GP_CHAT_WHISPER;
}
else
{
channel = ChatChannel.GP_CHAT_LOCAL;
pszMsg = text;
}
// Không gõ prefix thủ công thì sẽ dùng m_currentChannel đã được gán ở đầu hàm
SendChat(channel, pszMsg, nPack, nSlot);
return channel;
@@ -363,8 +388,11 @@ namespace BrewMonster.Scripts.ChatUI
{
string strModified = msg;
// 1. Filter bad words
CECUIManager.Instance.FilterBadWords(ref strModified);
if (channel is not ChatChannel.GP_CHAT_MISC)
{
// 1. Filter bad words
CECUIManager.Instance.FilterBadWords(ref strModified);
}
if (string.IsNullOrEmpty(strModified))
return;
+1 -1
View File
@@ -1,3 +1,3 @@
fileFormatVersion: 2
guid: 598459b2399743b5ba1eb55fd1d9611e
guid: 474cab0ba62d0eb45bdc28c5b381eb18
timeCreated: 1762861835
+96
View File
@@ -0,0 +1,96 @@
using System;
using System.Net;
using CSNetwork;
using CSNetwork.GPDataType;
using BrewMonster.Common;
using UnityEngine;
// Account login info struct
public struct AccountLoginInfo
{
public uint login_time;
public uint login_ip;
public uint current_ip;
public void Reset()
{
login_time = 0;
login_ip = 0;
current_ip = 0;
}
}
// Game runtime partial class
partial class CECGameRun
{
public AccountLoginInfo m_AccountLoginInfo = new AccountLoginInfo();
public bool m_bAccountLoginInfoShown = false;
public byte m_accountInfoFlag = 0;
public bool m_bAccountInfoShown = false;
public void ResetAccountLoginInfo()
{
m_AccountLoginInfo.Reset();
m_bAccountLoginInfoShown = true;
}
public void ShowAccountLoginInfo()
{
Debug.Log("[Cuong] ShowAccountLoginInfo");
if (!m_bAccountLoginInfoShown)
{
m_bAccountLoginInfoShown = true;
// Assuming CECUIConfig::Instance().GetGameUI().bEnableShowIP translates to true for now
bool bEnableShowIP = true;
if (bEnableShowIP)
{
// Last login time
DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime t = Epoch.AddSeconds(m_AccountLoginInfo.login_time).ToLocalTime();
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); // 9343
EventBus.Publish(new GameSession.ChatMessageEvent { context = textTime, channel = (byte)ChatChannel.GP_CHAT_SYSTEM });
Debug.Log($"[Cuong] ShowAccountLoginInfo {textTime}");
// Last login IP
string ipStr = new IPAddress((long)m_AccountLoginInfo.login_ip).ToString();
string textIp = string.Format("IP đăng nhập trước: {0}", ipStr); // 9344
EventBus.Publish(new GameSession.ChatMessageEvent { context = textIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM });
Debug.Log($"[Cuong] ShowAccountLoginInfo {textIp}");
// 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); // 9345
EventBus.Publish(new GameSession.ChatMessageEvent { context = textCurIp, channel = (byte)ChatChannel.GP_CHAT_SYSTEM });
Debug.Log($"[Cuong] ShowAccountLoginInfo {textCurIp}");
}
}
}
public void SetAccountInfoFlag(byte accountinfo_flag)
{
m_accountInfoFlag = accountinfo_flag;
m_bAccountInfoShown = false;
}
public void ShowAccountInfo()
{
if (!m_bAccountInfoShown)
{
m_bAccountInfoShown = true;
bool bEnableCompleteAccount = true;
if (bEnableCompleteAccount && ((m_accountInfoFlag & 0x03) != 0))
{
string text = "Hoàn tất thông tin tài khoản..."; // 9347
EventBus.Publish(new GameSession.ChatMessageEvent { context = text, channel = (byte)ChatChannel.GP_CHAT_SYSTEM });
Debug.Log($"[Cuong] ShowAccountInfo {text}");
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 598459b2399743b5ba1eb55fd1d9611e
timeCreated: 1762861835