80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using CSNetwork.GPDataType;
|
|
|
|
namespace BrewMonster.UI
|
|
{
|
|
/// <summary>
|
|
/// Code gốc bên C++
|
|
/// Class này làm về UI nên trong C# được chia ra
|
|
/// trong ChatInputHandler và ChatPanelUI
|
|
/// </summary>
|
|
public static class DlgChat
|
|
{
|
|
private static readonly Dictionary<ChatChannel, string> ChannelColors = new Dictionary<ChatChannel, string>
|
|
{
|
|
{ ChatChannel.GP_CHAT_LOCAL, "FFFFFF" },
|
|
{ ChatChannel.GP_CHAT_FARCRY, "FFE400" },
|
|
{ ChatChannel.GP_CHAT_TEAM, "00FF00" },
|
|
{ ChatChannel.GP_CHAT_FACTION, "00FFFC" },
|
|
{ ChatChannel.GP_CHAT_WHISPER, "0065FE" },
|
|
{ ChatChannel.GP_CHAT_DAMAGE, "C0C0C0" },
|
|
{ ChatChannel.GP_CHAT_FIGHT, "FF7E00" },
|
|
{ ChatChannel.GP_CHAT_TRADE, "FF742E" },
|
|
{ ChatChannel.GP_CHAT_SYSTEM, "BED293" },
|
|
{ ChatChannel.GP_CHAT_BROADCAST, "FF3600" },
|
|
{ ChatChannel.GP_CHAT_MISC, "9AA6FF" },
|
|
{ ChatChannel.GP_CHAT_INSTANCE, "EC0D3C" },
|
|
{ ChatChannel.GP_CHAT_SUPERFARCRY, "ff9b3e" },
|
|
{ ChatChannel.GP_CHAT_BATTLE, "FFFFFF" },
|
|
{ ChatChannel.GP_CHAT_COUNTRY, "FFFFFF" }
|
|
};
|
|
|
|
public const string NPC_COLOR = "C8FF64";
|
|
public const string KING_COLOR = "8A2BE2";
|
|
|
|
/// <summary>
|
|
/// Formats a message with TextMeshPro color tags based on the channel.
|
|
/// </summary>
|
|
public static string FormatMessage(string message, ChatChannel channel)
|
|
{
|
|
if (string.IsNullOrEmpty(message)) return string.Empty;
|
|
if (ChannelColors.TryGetValue(channel, out string hexColor))
|
|
return $"<color=#{hexColor}>{message}</color>";
|
|
return message;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Formats a message with a specific hex color tag.
|
|
/// </summary>
|
|
public static string FormatWithColor(string text, string hexColor)
|
|
{
|
|
if (string.IsNullOrEmpty(text)) return string.Empty;
|
|
return $"<color=#{hexColor}>{text}</color>";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the hex color string for a given channel.
|
|
/// Mirrors CDlgChat::GetChatColor in C++.
|
|
/// idPlayer is reserved for future per-player coloring (e.g. friend highlight).
|
|
/// </summary>
|
|
public static string GetChatColor(ChatChannel channel, int idPlayer = -1)
|
|
{
|
|
if (ChannelColors.TryGetValue(channel, out string hexColor))
|
|
return hexColor;
|
|
return "FFFFFF";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a channel icon/image prefix string.
|
|
/// Currently returns empty — placeholder for future TMP sprite implementation.
|
|
/// Mirrors GetChatChannelImage() in C++.
|
|
/// </summary>
|
|
public static string GetChatChannelImage(ChatChannel channel)
|
|
{
|
|
// TODO: return TMP sprite tag per channel when assets are ready
|
|
// e.g. return $"<sprite name=\"chat_icon_{channel}\">";
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|