Update newmenus.cpp (#884)

Fixes: #881

Co-authored-by: shel <2@shelru.ru>
This commit is contained in:
shel 2020-07-17 03:57:29 +04:00 committed by GitHub
parent f4fefd0bb4
commit ff2fc19b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -544,6 +544,20 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
/* Don't bother if there is only one page */ /* Don't bother if there is only one page */
if (pages > 1) if (pages > 1)
{ {
auto tempItemName = m_OptNames[abs(MENU_BACK)].chars();
if (this->useMultilingual)
{
const auto language = playerlang(player);
const auto definition = translate(this->amx, language, tempItemName);
if (definition)
{
tempItemName = definition;
}
}
if (flags & Display_Back) if (flags & Display_Back)
{ {
keys |= (1<<option++); keys |= (1<<option++);
@ -554,13 +568,13 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
"%s%d. \\w%s\n", "%s%d. \\w%s\n",
m_ItemColor.chars(), m_ItemColor.chars(),
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_BACK)].chars()); tempItemName);
} else { } else {
ke::SafeSprintf(buffer, ke::SafeSprintf(buffer,
sizeof(buffer), sizeof(buffer),
"%d. %s\n", "%d. %s\n",
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_BACK)].chars()); tempItemName);
} }
} else { } else {
option++; option++;
@ -570,13 +584,26 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
sizeof(buffer), sizeof(buffer),
"\\d%d. %s\n\\w", "\\d%d. %s\n\\w",
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_BACK)].chars()); tempItemName);
} else { } else {
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_BACK)].chars()); ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", tempItemName);
} }
} }
m_Text = m_Text + buffer; m_Text = m_Text + buffer;
tempItemName = m_OptNames[abs(MENU_MORE)].chars();
if (this->useMultilingual)
{
const auto language = playerlang(player);
const auto definition = translate(this->amx, language, tempItemName);
if (definition)
{
tempItemName = definition;
}
}
if (flags & Display_Next) if (flags & Display_Next)
{ {
keys |= (1<<option++); keys |= (1<<option++);
@ -587,13 +614,13 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
"%s%d. \\w%s\n", "%s%d. \\w%s\n",
m_ItemColor.chars(), m_ItemColor.chars(),
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_MORE)].chars()); tempItemName);
} else { } else {
ke::SafeSprintf(buffer, ke::SafeSprintf(buffer,
sizeof(buffer), sizeof(buffer),
"%d. %s\n", "%d. %s\n",
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_MORE)].chars()); tempItemName);
} }
} else { } else {
option++; option++;
@ -603,9 +630,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
sizeof(buffer), sizeof(buffer),
"\\d%d. %s\n\\w", "\\d%d. %s\n\\w",
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_MORE)].chars()); tempItemName);
} else { } else {
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_MORE)].chars()); ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", tempItemName);
} }
} }
m_Text = m_Text + buffer; m_Text = m_Text + buffer;
@ -617,6 +644,19 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
if ((items_per_page && !m_NeverExit) || (m_ForceExit && numItems < 10)) if ((items_per_page && !m_NeverExit) || (m_ForceExit && numItems < 10))
{ {
auto exitName = m_OptNames[abs(MENU_EXIT)].chars();
if (this->useMultilingual)
{
const auto language = playerlang(player);
const auto definition = translate(this->amx, language, exitName);
if (definition)
{
exitName = definition;
}
}
/* Visual pad has not been added yet */ /* Visual pad has not been added yet */
if (!items_per_page) if (!items_per_page)
m_Text = m_Text + "\n"; m_Text = m_Text + "\n";
@ -629,13 +669,13 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
"%s%d. \\w%s\n", "%s%d. \\w%s\n",
m_ItemColor.chars(), m_ItemColor.chars(),
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_EXIT)].chars()); exitName);
} else { } else {
ke::SafeSprintf(buffer, ke::SafeSprintf(buffer,
sizeof(buffer), sizeof(buffer),
"%d. %s\n", "%d. %s\n",
option == 10 ? 0 : option, option == 10 ? 0 : option,
m_OptNames[abs(MENU_EXIT)].chars()); exitName);
} }
m_Text = m_Text + buffer; m_Text = m_Text + buffer;
} }