Add MPROP_SHOWPAGE (#473)

This commit is contained in:
KliPPy 2018-07-18 17:10:37 +02:00 committed by Vincent Herbet
parent fba3d706fc
commit 98ab26671c
3 changed files with 14 additions and 2 deletions

View File

@ -92,7 +92,7 @@ bool CloseNewMenus(CPlayer *pPlayer)
Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"), 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), 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); CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(amx);
menuId = g_menucmds.registerMenuId(title, 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; m_Text = nullptr;
char buffer[255]; char buffer[255];
if (items_per_page && (pages != 1)) if (showPageNumber && items_per_page && (pages != 1))
{ {
if (m_AutoColors) if (m_AutoColors)
ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages); 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); unregisterSPForward(pMenu->pageCallback);
pMenu->pageCallback = callback; pMenu->pageCallback = callback;
break;
}
case MPROP_SHOWPAGE:
{
pMenu->showPageNumber = (get_amxaddr(amx, params[3]) != 0);
break; break;
} }
case MPROP_SET_NUMBER_COLOR: case MPROP_SET_NUMBER_COLOR:

View File

@ -31,6 +31,7 @@
#define MPROP_PADMENU 9 #define MPROP_PADMENU 9
#define MPROP_SET_NUMBER_COLOR 10 #define MPROP_SET_NUMBER_COLOR 10
#define MPROP_PAGE_CALLBACK 11 #define MPROP_PAGE_CALLBACK 11
#define MPROP_SHOWPAGE 12
typedef int (*MENUITEM_CALLBACK)(int, int, int); typedef int (*MENUITEM_CALLBACK)(int, int, int);
@ -125,6 +126,7 @@ public:
int func; int func;
bool isDestroying; bool isDestroying;
int pageCallback; int pageCallback;
bool showPageNumber;
public: public:
unsigned int items_per_page; unsigned int items_per_page;
}; };

View File

@ -81,6 +81,11 @@
*/ */
#define MPROP_PAGE_CALLBACK 11 #define MPROP_PAGE_CALLBACK 11
/**
* Whether to show the page number in menu title (param1 = bool, true = default)
*/
#define MPROP_SHOWPAGE 12
/** /**
* @deprecated * @deprecated
*/ */