add filter show UI
This commit is contained in:
@@ -8,6 +8,12 @@ using CSNetwork;
|
||||
|
||||
namespace BrewMonster.Scripts.ChatUI
|
||||
{
|
||||
public struct ChatChannelFilterChangedEvent
|
||||
{
|
||||
public ChatChannel channel;
|
||||
public ChatChannelFilterChangedEvent(ChatChannel c) { channel = c; }
|
||||
}
|
||||
|
||||
public class ChatInputHandler : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField inputField;
|
||||
@@ -88,16 +94,30 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
}
|
||||
|
||||
m_currentChannel = channel;
|
||||
var config = chatSystem.channelIcons.Find(c => c.channel == channel);
|
||||
if (config.prefix != null)
|
||||
|
||||
// Handle System channel input restriction
|
||||
if (m_currentChannel == ChatChannel.GP_CHAT_SYSTEM)
|
||||
{
|
||||
string currentText = inputField.text;
|
||||
currentText = RemoveKnownPrefix(currentText);
|
||||
inputField.text = config.prefix + currentText;
|
||||
inputField.interactable = false;
|
||||
inputField.text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
inputField.interactable = true;
|
||||
|
||||
var config = chatSystem.channelIcons.Find(c => c.channel == channel);
|
||||
if (config.prefix != null)
|
||||
{
|
||||
string currentText = inputField.text;
|
||||
currentText = RemoveKnownPrefix(currentText);
|
||||
inputField.text = config.prefix + currentText;
|
||||
}
|
||||
|
||||
inputField.ActivateInputField();
|
||||
inputField.MoveTextEnd(false);
|
||||
}
|
||||
|
||||
inputField.ActivateInputField();
|
||||
inputField.MoveTextEnd(false);
|
||||
EventBus.Publish(new ChatChannelFilterChangedEvent(m_currentChannel));
|
||||
}
|
||||
|
||||
private string RemoveKnownPrefix(string text)
|
||||
@@ -304,6 +324,12 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
HandleWhisper(text, nPack, nSlot);
|
||||
return ChatChannel.GP_CHAT_WHISPER;
|
||||
}
|
||||
else if (channel == ChatChannel.GP_CHAT_WHISPER)
|
||||
{
|
||||
// Cho phép chat kênh Whisper mượt mà mà không bắt buộc gõ ký tự "/" ở đầu
|
||||
HandleWhisper("/" + text, nPack, nSlot);
|
||||
return ChatChannel.GP_CHAT_WHISPER;
|
||||
}
|
||||
// Không gõ prefix thủ công thì sẽ dùng m_currentChannel đã được gán ở đầu hàm
|
||||
|
||||
SendChat(channel, pszMsg, nPack, nSlot);
|
||||
|
||||
Reference in New Issue
Block a user