mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
restore function to strip styling from player messages
This commit is contained in:
parent
ff8aba51ea
commit
d1709fad60
|
|
@ -6619,7 +6619,7 @@ wstring CMinecraftApp::EscapeHTMLString(const wstring& desc)
|
||||||
return finalString;
|
return finalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring CMinecraftApp::FormatChatMessage(const wstring& desc, bool applyColor)
|
wstring CMinecraftApp::FormatChatMessage(const wstring& desc, bool applyStyling)
|
||||||
{
|
{
|
||||||
static std::wregex IDS_Pattern(LR"(\{\*IDS_(\d+)\*\})"); //maybe theres a better way to do translateable IDS
|
static std::wregex IDS_Pattern(LR"(\{\*IDS_(\d+)\*\})"); //maybe theres a better way to do translateable IDS
|
||||||
static std::wstring_view colorFormatString = L"<font color=\"#%08x\">";
|
static std::wstring_view colorFormatString = L"<font color=\"#%08x\">";
|
||||||
|
|
@ -6627,59 +6627,62 @@ wstring CMinecraftApp::FormatChatMessage(const wstring& desc, bool applyColor)
|
||||||
wstring results = desc;
|
wstring results = desc;
|
||||||
wchar_t replacements[64];
|
wchar_t replacements[64];
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_0), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_0), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§0", replacements);
|
results = replaceAll(results, L"§0", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_1), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_1), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§1", replacements);
|
results = replaceAll(results, L"§1", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_2), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_2), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§2", replacements);
|
results = replaceAll(results, L"§2", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_3), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_3), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§3", replacements);
|
results = replaceAll(results, L"§3", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_4), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_4), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§4", replacements);
|
results = replaceAll(results, L"§4", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_5), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_5), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§5", replacements);
|
results = replaceAll(results, L"§5", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_6), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_6), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§6", replacements);
|
results = replaceAll(results, L"§6", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_7), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_7), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§7", replacements);
|
results = replaceAll(results, L"§7", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_8), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_8), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§8", replacements);
|
results = replaceAll(results, L"§8", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_9), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_9), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§9", replacements);
|
results = replaceAll(results, L"§9", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_a), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_a), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§a", replacements);
|
results = replaceAll(results, L"§a", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_b), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_b), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§b", replacements);
|
results = replaceAll(results, L"§b", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_c), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_c), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§c", replacements);
|
results = replaceAll(results, L"§c", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_d), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_d), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§d", replacements);
|
results = replaceAll(results, L"§d", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_e), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_e), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§e", replacements);
|
results = replaceAll(results, L"§e", replacements);
|
||||||
|
|
||||||
swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_f), 0xFFFFFFFF);
|
swprintf(replacements, 64, (applyStyling ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_f), 0xFFFFFFFF);
|
||||||
results = replaceAll(results, L"§f", replacements);
|
results = replaceAll(results, L"§f", replacements);
|
||||||
results = replaceAll(results, L"§r", replacements); //we only support color so reset is the same as white color
|
results = replaceAll(results, L"§r", replacements); //we only support color so reset is the same as white color
|
||||||
|
|
||||||
std::wsmatch match;
|
if (applyStyling) {
|
||||||
while (std::regex_search(results, match, IDS_Pattern)) {
|
std::wsmatch match;
|
||||||
results = replaceAll(results, match[0], app.GetString(std::stoi(match[1].str())));
|
while (std::regex_search(results, match, IDS_Pattern)) {
|
||||||
|
results = replaceAll(results, match[0], app.GetString(std::stoi(match[1].str())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ public:
|
||||||
int GetHTMLFontSize(EHTMLFontSize size);
|
int GetHTMLFontSize(EHTMLFontSize size);
|
||||||
wstring FormatHTMLString(int iPad, const wstring& desc, int shadowColour = 0xFFFFFFFF);
|
wstring FormatHTMLString(int iPad, const wstring& desc, int shadowColour = 0xFFFFFFFF);
|
||||||
wstring EscapeHTMLString(const wstring &desc);
|
wstring EscapeHTMLString(const wstring &desc);
|
||||||
wstring FormatChatMessage(const wstring& desc, bool applyColor = true);
|
wstring FormatChatMessage(const wstring& desc, bool applyStyling = true);
|
||||||
wstring GetActionReplacement(int iPad, unsigned char ucAction);
|
wstring GetActionReplacement(int iPad, unsigned char ucAction);
|
||||||
wstring GetVKReplacement(unsigned int uiVKey);
|
wstring GetVKReplacement(unsigned int uiVKey);
|
||||||
wstring GetIconReplacement(unsigned int uiIcon);
|
wstring GetIconReplacement(unsigned int uiIcon);
|
||||||
|
|
|
||||||
|
|
@ -679,7 +679,7 @@ void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wstring formatted = L"<" + player->name + L"> " + message;
|
wstring formatted = L"<" + player->name + L"> " + message;
|
||||||
server->getPlayers()->broadcastAll(shared_ptr<ChatPacket>(new ChatPacket(formatted)));
|
server->getPlayers()->broadcastAll(shared_ptr<ChatPacket>(new ChatPacket(app.FormatChatMessage(formatted, false))));
|
||||||
chatSpamTickCount += SharedConstants::TICKS_PER_SECOND;
|
chatSpamTickCount += SharedConstants::TICKS_PER_SECOND;
|
||||||
if (chatSpamTickCount > SharedConstants::TICKS_PER_SECOND * 10)
|
if (chatSpamTickCount > SharedConstants::TICKS_PER_SECOND * 10)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue