mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
restore non styled chat size check
This commit is contained in:
parent
7eef3b6069
commit
15989a9ef6
|
|
@ -17,29 +17,6 @@ bool ChatScreen::isAllowedChatChar(wchar_t c)
|
||||||
return c >= 0x20 && (c == L'\u00A7' || allowedChars.empty() || allowedChars.find(c) != wstring::npos);
|
return c >= 0x20 && (c == L'\u00A7' || allowedChars.empty() || allowedChars.find(c) != wstring::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VisibleCharLength(wstring message) {
|
|
||||||
static std::unordered_set<wchar_t> validStyleCharacters = {
|
|
||||||
L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9',
|
|
||||||
L'a', L'b', L'c', L'd', L'e', L'f',
|
|
||||||
};
|
|
||||||
int results = 0;
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < message.size(); i++) {
|
|
||||||
wchar_t _char = message[i];
|
|
||||||
if (_char == L'§' && (i + 1) < message.size()) {
|
|
||||||
wchar_t colorChar = message[i + 1];
|
|
||||||
if (validStyleCharacters.find(colorChar) != validStyleCharacters.end()) {
|
|
||||||
i++; //do this so it increments 2 instead of 1
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatScreen::ChatScreen()
|
ChatScreen::ChatScreen()
|
||||||
{
|
{
|
||||||
frame = 0;
|
frame = 0;
|
||||||
|
|
@ -154,7 +131,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
|
||||||
cursorIndex--;
|
cursorIndex--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isAllowedChatChar(ch) && VisibleCharLength(message) < SharedConstants::maxVisibleLength)
|
if (isAllowedChatChar(ch) && static_cast<int>(message.length()) < SharedConstants::maxVisibleLength)
|
||||||
{
|
{
|
||||||
message.insert(cursorIndex, 1, ch);
|
message.insert(cursorIndex, 1, ch);
|
||||||
cursorIndex++;
|
cursorIndex++;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue