From 98ab26671c53492e39630d59a69aca0fdcc9d866 Mon Sep 17 00:00:00 2001 From: KliPPy Date: Wed, 18 Jul 2018 17:10:37 +0200 Subject: [PATCH] Add MPROP_SHOWPAGE (#473) --- amxmodx/newmenus.cpp | 9 +++++++-- amxmodx/newmenus.h | 2 ++ plugins/include/newmenus.inc | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 5e6d0773..b16b9b57 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -92,7 +92,7 @@ bool CloseNewMenus(CPlayer *pPlayer) Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"), m_NeverExit(false), m_AutoColors(g_coloredmenus), thisId(0), func(fid), -isDestroying(false), pageCallback(-1), items_per_page(7) +isDestroying(false), pageCallback(-1), showPageNumber(true), items_per_page(7) { CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx); menuId = g_menucmds.registerMenuId(title, amx); @@ -357,7 +357,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys) m_Text = nullptr; char buffer[255]; - if (items_per_page && (pages != 1)) + if (showPageNumber && items_per_page && (pages != 1)) { if (m_AutoColors) ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages); @@ -983,6 +983,11 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params) unregisterSPForward(pMenu->pageCallback); pMenu->pageCallback = callback; + break; + } + case MPROP_SHOWPAGE: + { + pMenu->showPageNumber = (get_amxaddr(amx, params[3]) != 0); break; } case MPROP_SET_NUMBER_COLOR: diff --git a/amxmodx/newmenus.h b/amxmodx/newmenus.h index 936188c3..df132df1 100755 --- a/amxmodx/newmenus.h +++ b/amxmodx/newmenus.h @@ -31,6 +31,7 @@ #define MPROP_PADMENU 9 #define MPROP_SET_NUMBER_COLOR 10 #define MPROP_PAGE_CALLBACK 11 +#define MPROP_SHOWPAGE 12 typedef int (*MENUITEM_CALLBACK)(int, int, int); @@ -125,6 +126,7 @@ public: int func; bool isDestroying; int pageCallback; + bool showPageNumber; public: unsigned int items_per_page; }; diff --git a/plugins/include/newmenus.inc b/plugins/include/newmenus.inc index 4ded31d9..98faad81 100644 --- a/plugins/include/newmenus.inc +++ b/plugins/include/newmenus.inc @@ -81,6 +81,11 @@ */ #define MPROP_PAGE_CALLBACK 11 +/** + * Whether to show the page number in menu title (param1 = bool, true = default) + */ +#define MPROP_SHOWPAGE 12 + /** * @deprecated */