chat message config
This commit is contained in:
parent
72e2910a68
commit
711350f50c
6 changed files with 178 additions and 12 deletions
|
|
@ -23,7 +23,6 @@ namespace src
|
||||||
public CCSGameRules? GameRules { get; set; }
|
public CCSGameRules? GameRules { get; set; }
|
||||||
private ConcurrentBag<string> ManifestResources { get; set; } = [ "models/actors/ghost_speaker.vmdl" ];
|
private ConcurrentBag<string> ManifestResources { get; set; } = [ "models/actors/ghost_speaker.vmdl" ];
|
||||||
public IWasdMenuManager? MenuManager;
|
public IWasdMenuManager? MenuManager;
|
||||||
public const string Tag = "jRandomSkills";
|
|
||||||
|
|
||||||
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
||||||
public override string ModuleAuthor => "D3X, Juzlus";
|
public override string ModuleAuthor => "D3X, Juzlus";
|
||||||
|
|
|
||||||
|
|
@ -454,8 +454,7 @@
|
||||||
"bombsite_b": "Bombsite B",
|
"bombsite_b": "Bombsite B",
|
||||||
|
|
||||||
"teammate_skills": "Your teammates' skills",
|
"teammate_skills": "Your teammates' skills",
|
||||||
"summary_start": "Summary of the last round",
|
"summary": "Summary of the last round",
|
||||||
"summary_end": "=======================================",
|
|
||||||
|
|
||||||
"menu_controlls_scroll": "W/S - Scroll",
|
"menu_controlls_scroll": "W/S - Scroll",
|
||||||
"menu_controlls_padding": " | ",
|
"menu_controlls_padding": " | ",
|
||||||
|
|
|
||||||
|
|
@ -434,11 +434,11 @@ namespace src.player
|
||||||
|
|
||||||
if (Config.LoadedConfig.SummaryAfterTheRound && !string.IsNullOrEmpty(skillsText))
|
if (Config.LoadedConfig.SummaryAfterTheRound && !string.IsNullOrEmpty(skillsText))
|
||||||
{
|
{
|
||||||
SkillUtils.PrintToChat(player, string.Empty, title: player.GetTranslation("summary_start"), border: "t");
|
SkillUtils.PrintToChat(player, string.Empty, title: player.GetTranslation("summary"), border: "t");
|
||||||
foreach (string text in skillsText.Split("\n"))
|
foreach (string text in skillsText.Split("\n"))
|
||||||
if (!string.IsNullOrEmpty(text))
|
if (!string.IsNullOrEmpty(text))
|
||||||
SkillUtils.PrintToChat(player, text, title: player.GetTranslation("teammate_skills"), border: "");
|
SkillUtils.PrintToChat(player, text, title: player.GetTranslation("teammate_skills"), border: "");
|
||||||
SkillUtils.PrintToChat(player, string.Empty, title: player.GetTranslation("summary_start"), border: "b");
|
SkillUtils.PrintToChat(player, string.Empty, border: "b");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ namespace src.utils
|
||||||
public bool DisableSkillsOnRoundEnd { get; set; }
|
public bool DisableSkillsOnRoundEnd { get; set; }
|
||||||
public LanguageSystem LanguageSystem { get; set; }
|
public LanguageSystem LanguageSystem { get; set; }
|
||||||
public HtmlHudCustomisation HtmlHudCustomisation { get; set; }
|
public HtmlHudCustomisation HtmlHudCustomisation { get; set; }
|
||||||
|
public ChatMessage ChatMessage { get; set; }
|
||||||
public NormalCommands NormalCommands { get; set; }
|
public NormalCommands NormalCommands { get; set; }
|
||||||
public VotingCommands VotingCommands { get; set; }
|
public VotingCommands VotingCommands { get; set; }
|
||||||
|
|
||||||
|
|
@ -143,6 +144,18 @@ namespace src.utils
|
||||||
WSADMenuControllsLineColor3 = "green",
|
WSADMenuControllsLineColor3 = "green",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChatMessage = new ChatMessage
|
||||||
|
{
|
||||||
|
MaxWidth = 1280,
|
||||||
|
LineSymbol = '―',
|
||||||
|
LineColor = "\x04",
|
||||||
|
LineShow = true,
|
||||||
|
InfoPlayerNameColor = "\x02",
|
||||||
|
InfoSkillColor = "\x06",
|
||||||
|
InfoMessageShow = true,
|
||||||
|
TagFormat = "\x02◢◆◤ {TAG} ◥◆◣",
|
||||||
|
};
|
||||||
|
|
||||||
NormalCommands = new NormalCommands
|
NormalCommands = new NormalCommands
|
||||||
{
|
{
|
||||||
SetSkillCommand = new NormalCommand("ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", "@jRandmosSkills/admin"),
|
SetSkillCommand = new NormalCommand("ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", "@jRandmosSkills/admin"),
|
||||||
|
|
@ -168,6 +181,18 @@ namespace src.utils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ChatMessage
|
||||||
|
{
|
||||||
|
public required float MaxWidth { get; set; }
|
||||||
|
public required char LineSymbol { get; set; }
|
||||||
|
public required string LineColor { get; set; }
|
||||||
|
public required bool LineShow { get; set; }
|
||||||
|
public required string InfoPlayerNameColor { get; set; }
|
||||||
|
public required string InfoSkillColor { get; set; }
|
||||||
|
public required bool InfoMessageShow { get; set; }
|
||||||
|
public required string TagFormat { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class HtmlHudCustomisation
|
public class HtmlHudCustomisation
|
||||||
{
|
{
|
||||||
public required string HeaderLineColor { get; set; }
|
public required string HeaderLineColor { get; set; }
|
||||||
|
|
|
||||||
138
jRandomSkills - SRC Files/src/utils/MeansureString.cs
Normal file
138
jRandomSkills - SRC Files/src/utils/MeansureString.cs
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
using CounterStrikeSharp.API;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace src.player;
|
||||||
|
|
||||||
|
public static class MeansureString
|
||||||
|
{
|
||||||
|
static readonly float DefaultCharWidth = 22.25f;
|
||||||
|
static readonly Dictionary<char, float> CharWidth = new()
|
||||||
|
{
|
||||||
|
['0'] = 22.25f,
|
||||||
|
['1'] = 22.25f,
|
||||||
|
['2'] = 22.25f,
|
||||||
|
['3'] = 22.25f,
|
||||||
|
['4'] = 22.25f,
|
||||||
|
['5'] = 22.25f,
|
||||||
|
['6'] = 22.25f,
|
||||||
|
['7'] = 22.25f,
|
||||||
|
['8'] = 22.25f,
|
||||||
|
['9'] = 22.25f,
|
||||||
|
['a'] = 22.25f,
|
||||||
|
['b'] = 22.25f,
|
||||||
|
['c'] = 20.00f,
|
||||||
|
['d'] = 22.25f,
|
||||||
|
['e'] = 22.25f,
|
||||||
|
['f'] = 11.11f,
|
||||||
|
['g'] = 22.25f,
|
||||||
|
['h'] = 22.25f,
|
||||||
|
['i'] = 8.89f,
|
||||||
|
['j'] = 8.89f,
|
||||||
|
['k'] = 20.00f,
|
||||||
|
['l'] = 8.89f,
|
||||||
|
['m'] = 33.33f,
|
||||||
|
['n'] = 22.25f,
|
||||||
|
['o'] = 22.25f,
|
||||||
|
['p'] = 22.25f,
|
||||||
|
['q'] = 22.25f,
|
||||||
|
['r'] = 13.33f,
|
||||||
|
['s'] = 20.00f,
|
||||||
|
['t'] = 11.11f,
|
||||||
|
['u'] = 22.25f,
|
||||||
|
['v'] = 20.00f,
|
||||||
|
['w'] = 28.89f,
|
||||||
|
['x'] = 20.00f,
|
||||||
|
['y'] = 20.00f,
|
||||||
|
['z'] = 20.00f,
|
||||||
|
['A'] = 26.69f,
|
||||||
|
['B'] = 26.69f,
|
||||||
|
['C'] = 28.89f,
|
||||||
|
['D'] = 28.89f,
|
||||||
|
['E'] = 26.69f,
|
||||||
|
['F'] = 24.44f,
|
||||||
|
['G'] = 31.11f,
|
||||||
|
['H'] = 28.89f,
|
||||||
|
['I'] = 11.11f,
|
||||||
|
['J'] = 20.00f,
|
||||||
|
['K'] = 26.69f,
|
||||||
|
['L'] = 22.25f,
|
||||||
|
['M'] = 33.33f,
|
||||||
|
['N'] = 28.89f,
|
||||||
|
['O'] = 31.11f,
|
||||||
|
['P'] = 26.69f,
|
||||||
|
['Q'] = 31.11f,
|
||||||
|
['R'] = 28.89f,
|
||||||
|
['S'] = 26.69f,
|
||||||
|
['T'] = 24.44f,
|
||||||
|
['U'] = 28.89f,
|
||||||
|
['V'] = 26.69f,
|
||||||
|
['W'] = 37.75f,
|
||||||
|
['X'] = 26.69f,
|
||||||
|
['Y'] = 26.69f,
|
||||||
|
['Z'] = 24.44f,
|
||||||
|
['\''] = 7.64f,
|
||||||
|
['!'] = 11.11f,
|
||||||
|
['@'] = 40.61f,
|
||||||
|
['#'] = 22.25f,
|
||||||
|
['$'] = 22.25f,
|
||||||
|
['%'] = 35.56f,
|
||||||
|
['^'] = 18.77f,
|
||||||
|
['&'] = 26.69f,
|
||||||
|
['*'] = 15.56f,
|
||||||
|
['('] = 13.33f,
|
||||||
|
[')'] = 13.33f,
|
||||||
|
['_'] = 22.25f,
|
||||||
|
['-'] = 13.33f,
|
||||||
|
['+'] = 23.36f,
|
||||||
|
['='] = 23.36f,
|
||||||
|
[','] = 11.11f,
|
||||||
|
['.'] = 11.11f,
|
||||||
|
[';'] = 11.11f,
|
||||||
|
[':'] = 11.11f,
|
||||||
|
['<'] = 23.36f,
|
||||||
|
['>'] = 23.36f,
|
||||||
|
['/'] = 11.11f,
|
||||||
|
['?'] = 22.25f,
|
||||||
|
['\\'] = 11.11f,
|
||||||
|
['|'] = 10.39f,
|
||||||
|
['`'] = 13.33f,
|
||||||
|
['~'] = 23.36f,
|
||||||
|
['"'] = 14.20f,
|
||||||
|
[' '] = 11.11f,
|
||||||
|
['―'] = 40.00f,
|
||||||
|
['◢'] = 30.00f,
|
||||||
|
['◆'] = 30.00f,
|
||||||
|
['◤'] = 30.00f,
|
||||||
|
};
|
||||||
|
|
||||||
|
private static float GetWidth(string s)
|
||||||
|
{
|
||||||
|
float w = 0;
|
||||||
|
foreach (char c in s)
|
||||||
|
w += CharWidth.TryGetValue(c, out var cw) ? cw : DefaultCharWidth;
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string StripColors(string s)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(s)) return s;
|
||||||
|
return Regex.Replace(s, @"[\x01-\x10]", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetTextDashed(string content, float targetWidth, char symbol, string color)
|
||||||
|
{
|
||||||
|
string cleanContent = StripColors(content);
|
||||||
|
float contentWidth = GetWidth(cleanContent);
|
||||||
|
float dashWidth = CharWidth.TryGetValue(symbol, out var cw) ? cw : DefaultCharWidth;
|
||||||
|
|
||||||
|
float remaining = targetWidth - contentWidth;
|
||||||
|
|
||||||
|
if (remaining <= 0) return content;
|
||||||
|
int totalDashes = (int)Math.Floor(remaining / dashWidth);
|
||||||
|
|
||||||
|
int left = totalDashes / 2;
|
||||||
|
int right = totalDashes - left;
|
||||||
|
|
||||||
|
return color + new string(symbol, left) + content + color + new string(symbol, right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,14 +20,19 @@ namespace src.utils
|
||||||
private static readonly MemoryFunctionWithReturn<IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, int> HEGrenadeProjectile_CreateFunc = new(GameData.GetSignature("HEGrenadeProjectile_CreateFunc"));
|
private static readonly MemoryFunctionWithReturn<IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, int> HEGrenadeProjectile_CreateFunc = new(GameData.GetSignature("HEGrenadeProjectile_CreateFunc"));
|
||||||
private static readonly MemoryFunctionVoid<nint, float, RoundEndReason, nint, nint> TerminateRoundFunc = new(GameData.GetSignature("CCSGameRules_TerminateRound"));
|
private static readonly MemoryFunctionVoid<nint, float, RoundEndReason, nint, nint> TerminateRoundFunc = new(GameData.GetSignature("CCSGameRules_TerminateRound"));
|
||||||
|
|
||||||
public static void PrintToChat(CCSPlayerController player, string msg, string border = "tb", string title = jRandomSkills.Tag)
|
public static void PrintToChat(CCSPlayerController player, string msg, string border = "tb", string? title = null)
|
||||||
{
|
{
|
||||||
if (border.Contains('t'))
|
var config = Config.LoadedConfig.ChatMessage;
|
||||||
player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◢◆◤ {title} ◥◆◣{ChatColors.Green}―――――――――――");
|
float maxWidth = config.MaxWidth;
|
||||||
if (!string.IsNullOrEmpty(msg))
|
char symbol = config.LineSymbol;
|
||||||
player.PrintToChat($" {ChatColors.Green} {msg}");
|
if (string.IsNullOrEmpty(title)) title = player.GetTranslation("jRandomSkills");
|
||||||
if (border.Contains('b'))
|
|
||||||
player.PrintToChat($" {ChatColors.Green}―――――――――――――――{new string('―', title.Length)}―――――――――――――――");
|
if (border.Contains('t') && config.LineShow)
|
||||||
|
player.PrintToChat($" {MeansureString.GetTextDashed($"{(config.TagFormat.Contains("{TAG}") ? config.TagFormat.Replace("{TAG}", title) : $"\u0002◢◆◤ {title} ◥◆◣")}", maxWidth, symbol, config.LineColor)}");
|
||||||
|
if (!string.IsNullOrEmpty(msg) && config.InfoMessageShow)
|
||||||
|
player.PrintToChat($" {config.InfoSkillColor} {msg.Replace("\x02", config.InfoPlayerNameColor).Replace("\x06", config.InfoSkillColor)}");
|
||||||
|
if (border.Contains('b') && config.LineShow)
|
||||||
|
player.PrintToChat($" {MeansureString.GetTextDashed("", maxWidth, symbol, config.LineColor)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsFreezeTime()
|
public static bool IsFreezeTime()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue