I still haven't fixed this problem. How is your progress?
Dear God, should I check that file for specific directions? Should we look at that macro definition?The issue is likely related to encoding, as it may not support any characters other than letters and numbers (please check the macro definitions in your original code).
What language are you planning to use for it?View attachment 276864
Other areas are displaying normally - only one system announcement has garbled text. But English letters and numbers display system announcements normally
ChineseWhat language are you planning to use for it?
Hello, Great GodWhat language are you planning to use for it?
The version I want to modify is [page 22] Culture Aces :::::https://forum.ragezone.com/threads/vs22-culture-aces.1233508/What language are you planning to use for it?
void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
AnnounceData data;
auto pOldFont = g_Neuz.m_2DRender.GetFont();
g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);
CEditString str;
str.SetParsingString(strAnnounce.c_str());
auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width();
std::string character;
std::uint16_t index = 0;
std::uint16_t charSize = 0;
for (size_t i = 0; i < strAnnounce.size(); i += charSize) {
textData chardata;
charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2;
chardata.m_char = strAnnounce[i];
if (charSize == 2 && i + 1 < strAnnounce.size()) {
chardata.m_char = strAnnounce[i+1];
}
CEditString strEdit;
strEdit.SetParsingString(character.c_str());
chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
data.m_strAnnounce.push_back(chardata);
character.append(strAnnounce.substr(i, charSize));
index++;
}
g_Neuz.m_2DRender.SetFont(pOldFont);
data.m_nPlayerCasterIndex = nPlayerIndex;
m_vTopAnnounces.push_back(data);
}
void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
AnnounceData data;
auto pOldFont = g_Neuz.m_2DRender.GetFont();
g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);
CEditString str;
str.SetParsingString(strAnnounce.c_str());
const std::uint16_t nRectWidth = 450;
int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2);
auto nRightPosition = pointX + nRectWidth;
std::string character;
std::uint16_t index = 0;
std::uint16_t charSize = 0;
for (size_t i = 0; i < strAnnounce.size(); i += charSize) {
textData chardata;
charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2;
chardata.m_char = strAnnounce[i];
if (charSize == 2 && i + 1 < strAnnounce.size()) {
chardata.m_char = strAnnounce[i+1];
}
CEditString strEdit;
strEdit.SetParsingString(character.c_str());
chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
data.m_strAnnounce.push_back(chardata);
character.append(strAnnounce.substr(i, charSize));
index++;
}
g_Neuz.m_2DRender.SetFont(pOldFont);
data.m_nPlayerCasterIndex = nPlayerIndex;
m_vCenteredAnnounces.push_back(data);
}
It doesn't work, but the garbled code changes the shape,Not sure if this will work, but you can give it a try (not tested yet).
Try replacing the AddTopAnnounce and AddCenterAnnounce functions with the code below:
C++:void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) { AnnounceData data; auto pOldFont = g_Neuz.m_2DRender.GetFont(); g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText); CEditString str; str.SetParsingString(strAnnounce.c_str()); auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width(); std::string character; std::uint16_t index = 0; std::uint16_t charSize = 0; for (size_t i = 0; i < strAnnounce.size(); i += charSize) { textData chardata; charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2; chardata.m_char = strAnnounce[i]; if (charSize == 2 && i + 1 < strAnnounce.size()) { chardata.m_char = strAnnounce[i+1]; } CEditString strEdit; strEdit.SetParsingString(character.c_str()); chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx; data.m_strAnnounce.push_back(chardata); character.append(strAnnounce.substr(i, charSize)); index++; } g_Neuz.m_2DRender.SetFont(pOldFont); data.m_nPlayerCasterIndex = nPlayerIndex; m_vTopAnnounces.push_back(data); } void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) { AnnounceData data; auto pOldFont = g_Neuz.m_2DRender.GetFont(); g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText); CEditString str; str.SetParsingString(strAnnounce.c_str()); const std::uint16_t nRectWidth = 450; int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2); auto nRightPosition = pointX + nRectWidth; std::string character; std::uint16_t index = 0; std::uint16_t charSize = 0; for (size_t i = 0; i < strAnnounce.size(); i += charSize) { textData chardata; charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2; chardata.m_char = strAnnounce[i]; if (charSize == 2 && i + 1 < strAnnounce.size()) { chardata.m_char = strAnnounce[i+1]; } CEditString strEdit; strEdit.SetParsingString(character.c_str()); chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx; data.m_strAnnounce.push_back(chardata); character.append(strAnnounce.substr(i, charSize)); index++; } g_Neuz.m_2DRender.SetFont(pOldFont); data.m_nPlayerCasterIndex = nPlayerIndex; m_vCenteredAnnounces.push_back(data); }
void CAnnounceRenderer::RenderTopAnnounces(C2DRender* p2DRender) {
CPoint point = CPoint(50, 5);
if (m_vTopAnnounces.empty()) return;
auto itAnnounce = m_vTopAnnounces.begin();
RenderRectangles(p2DRender, CRect(point.x, point.y - 5, g_Neuz.m_2DRender.m_clipRect.Width() - 50, point.y + 20), itAnnounce->m_nAlpha, 50);
for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end(); )
{
if (itLetter->m_nPositionX <= g_Neuz.m_2DRender.m_clipRect.Width())
{
std::string strLetter = itLetter->m_char;
CEditString string;
string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
itLetter->m_nPositionX -= 2; // scroll speed
if (itLetter->m_nPositionX <= 0)
{
itLetter->m_nPositionX += g_Neuz.m_2DRender.m_clipRect.Width();
itLetter->m_nRoundsCount++;
if (itLetter->m_nRoundsCount >= MAX_ROUNDS_TOP)
itLetter = itAnnounce->m_strAnnounce.erase(itLetter);
else
++itLetter;
}
else
{
++itLetter;
}
}
else
{
++itLetter;
}
}
if (itAnnounce->m_strAnnounce.empty()) {
if (itAnnounce->m_tDelay == 0) {
if (std::distance(itAnnounce, m_vTopAnnounces.end()) == 1)
itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
else
m_vTopAnnounces.erase(itAnnounce);
}
}
}
void CAnnounceRenderer::RenderCenterAnnounces(C2DRender* p2DRender) {
auto offSetY = (184 * p2DRender->m_clipRect.Height() / 768) - 120;
if (m_vCenteredAnnounces.empty()) return;
auto itAnnounce = m_vCenteredAnnounces.begin();
std::string strFull;
for (const auto& text : itAnnounce->m_strAnnounce) {
strFull += text.m_char; // correct, supports full UTF-8 characters
}
CEditString str;
str.SetParsingString(strFull.c_str());
const std::uint16_t nRectWidth = 450;
CPoint point = CPoint((p2DRender->m_clipRect.Width() / 2) - (nRectWidth / 2), offSetY);
RenderRectangles(p2DRender, CRect(point.x, point.y - 5, point.x + nRectWidth, point.y + 20), itAnnounce->m_nAlpha, 50);
for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end(); )
{
if (itLetter->m_nPositionX <= point.x + nRectWidth && itLetter->m_nPositionX >= point.x)
{
std::string strLetter = itLetter->m_char;
CEditString string;
string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
}
itLetter->m_nPositionX -= 2;
++itLetter;
}
if (itAnnounce->m_strAnnounce.empty()) {
if (itAnnounce->m_tDelay == 0) {
if( std::distance(itAnnounce, m_vCenteredAnnounces.end()) == 1)
itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
else
m_vCenteredAnnounces.erase(itAnnounce);
}
}
}
struct textData {
char m_char = { 0, };
std::int32_t m_nPositionX = 0;
std::uint8_t m_nRoundsCount = 0;
};
struct AnnounceData {
std::vector<textData> m_strAnnounce;
std::uint32_t m_nPlayerCasterIndex = 0;
__time64_t m_tDelay = 0;
std::int32_t m_nAlpha = ALPHA_BASE;
};
struct textData
{
std::string m_char; // Full UTF-8 character
std::int32_t m_nPositionX = 0;
std::uint8_t m_nRoundsCount = 0;
};
struct AnnounceData {
std::vector<textData> m_strAnnounce; // now contains full UTF-8 character data
std::uint32_t m_nPlayerCasterIndex = 0;
__time64_t m_tDelay = 0;
std::int32_t m_nAlpha = ALPHA_BASE;
};
Microsoft YaHei
It doesn't work, but the garbled code changes the shape,Not sure if this will work, but you can give it a try (not tested yet).
Try replacing the AddTopAnnounce and AddCenterAnnounce functions with the code below:
C++:void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) { AnnounceData data; auto pOldFont = g_Neuz.m_2DRender.GetFont(); g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText); CEditString str; str.SetParsingString(strAnnounce.c_str()); auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width(); std::string character; std::uint16_t index = 0; std::uint16_t charSize = 0; for (size_t i = 0; i < strAnnounce.size(); i += charSize) { textData chardata; charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2; chardata.m_char = strAnnounce[i]; if (charSize == 2 && i + 1 < strAnnounce.size()) { chardata.m_char = strAnnounce[i+1]; } CEditString strEdit; strEdit.SetParsingString(character.c_str()); chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx; data.m_strAnnounce.push_back(chardata); character.append(strAnnounce.substr(i, charSize)); index++; } g_Neuz.m_2DRender.SetFont(pOldFont); data.m_nPlayerCasterIndex = nPlayerIndex; m_vTopAnnounces.push_back(data); } void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) { AnnounceData data; auto pOldFont = g_Neuz.m_2DRender.GetFont(); g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText); CEditString str; str.SetParsingString(strAnnounce.c_str()); const std::uint16_t nRectWidth = 450; int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2); auto nRightPosition = pointX + nRectWidth; std::string character; std::uint16_t index = 0; std::uint16_t charSize = 0; for (size_t i = 0; i < strAnnounce.size(); i += charSize) { textData chardata; charSize = (strAnnounce[i] & 0x80) == 0 ? 1 : 2; chardata.m_char = strAnnounce[i]; if (charSize == 2 && i + 1 < strAnnounce.size()) { chardata.m_char = strAnnounce[i+1]; } CEditString strEdit; strEdit.SetParsingString(character.c_str()); chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx; data.m_strAnnounce.push_back(chardata); character.append(strAnnounce.substr(i, charSize)); index++; } g_Neuz.m_2DRender.SetFont(pOldFont); data.m_nPlayerCasterIndex = nPlayerIndex; m_vCenteredAnnounces.push_back(data); }
after this dont forget to create a new font on ITheme.cppThis should fix your problem
C#:void CAnnounceRenderer::RenderTopAnnounces(C2DRender* p2DRender) { CPoint point = CPoint(50, 5); if (m_vTopAnnounces.empty()) return; auto itAnnounce = m_vTopAnnounces.begin(); RenderRectangles(p2DRender, CRect(point.x, point.y - 5, g_Neuz.m_2DRender.m_clipRect.Width() - 50, point.y + 20), itAnnounce->m_nAlpha, 50); for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end(); ) { if (itLetter->m_nPositionX <= g_Neuz.m_2DRender.m_clipRect.Width()) { std::string strLetter = itLetter->m_char; CEditString string; string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254)); p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string); itLetter->m_nPositionX -= 2; // scroll speed if (itLetter->m_nPositionX <= 0) { itLetter->m_nPositionX += g_Neuz.m_2DRender.m_clipRect.Width(); itLetter->m_nRoundsCount++; if (itLetter->m_nRoundsCount >= MAX_ROUNDS_TOP) itLetter = itAnnounce->m_strAnnounce.erase(itLetter); else ++itLetter; } else { ++itLetter; } } else { ++itLetter; } } if (itAnnounce->m_strAnnounce.empty()) { if (itAnnounce->m_tDelay == 0) { if (std::distance(itAnnounce, m_vTopAnnounces.end()) == 1) itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY; else m_vTopAnnounces.erase(itAnnounce); } } } void CAnnounceRenderer::RenderCenterAnnounces(C2DRender* p2DRender) { auto offSetY = (184 * p2DRender->m_clipRect.Height() / 768) - 120; if (m_vCenteredAnnounces.empty()) return; auto itAnnounce = m_vCenteredAnnounces.begin(); std::string strFull; for (const auto& text : itAnnounce->m_strAnnounce) { strFull += text.m_char; // correct, supports full UTF-8 characters } CEditString str; str.SetParsingString(strFull.c_str()); const std::uint16_t nRectWidth = 450; CPoint point = CPoint((p2DRender->m_clipRect.Width() / 2) - (nRectWidth / 2), offSetY); RenderRectangles(p2DRender, CRect(point.x, point.y - 5, point.x + nRectWidth, point.y + 20), itAnnounce->m_nAlpha, 50); for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end(); ) { if (itLetter->m_nPositionX <= point.x + nRectWidth && itLetter->m_nPositionX >= point.x) { std::string strLetter = itLetter->m_char; CEditString string; string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254)); p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string); } itLetter->m_nPositionX -= 2; ++itLetter; } if (itAnnounce->m_strAnnounce.empty()) { if (itAnnounce->m_tDelay == 0) { if( std::distance(itAnnounce, m_vCenteredAnnounces.end()) == 1) itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY; else m_vCenteredAnnounces.erase(itAnnounce); } } }
Then replace the
C++:struct textData { char m_char = { 0, }; std::int32_t m_nPositionX = 0; std::uint8_t m_nRoundsCount = 0; }; struct AnnounceData { std::vector<textData> m_strAnnounce; std::uint32_t m_nPlayerCasterIndex = 0; __time64_t m_tDelay = 0; std::int32_t m_nAlpha = ALPHA_BASE; };
to
C++:struct textData { std::string m_char; // Full UTF-8 character std::int32_t m_nPositionX = 0; std::uint8_t m_nRoundsCount = 0; }; struct AnnounceData { std::vector<textData> m_strAnnounce; // now contains full UTF-8 character data std::uint32_t m_nPlayerCasterIndex = 0; __time64_t m_tDelay = 0; std::int32_t m_nAlpha = ALPHA_BASE; };
after this dont forget to create a new font on ITheme.cpp
Set the font to this.
C++:Microsoft YaHei
Only the new bulletin system can be blocked. It is normal to use the original system bulletinisn't it much easier to use the game's engine own messaging system instead of creating a whole new function for it? It will than support all ime's through the editstring info? Am i missing something?
Have you solved it? No matter how I change the language and font encoding, I still can't change the display of garbled characters. I think it's because the encoding in AnnounceRedrader.cpp is not supported, only English and numbers are supported, and it cannot recognize other languagesOnly the new bulletin system can be blocked. It is normal to use the original system bulletin
This part of code is shieldedHave you solved it? No matter how I change the language and font encoding, I still can't change the display of garbled characters. I think it's because the encoding in AnnounceRedrader.cpp is not supported, only English and numbers are supported, and it cannot recognize other languages