Skip to content

Commit

Permalink
Add MPROP_SHOWPAGE (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsKliPPy authored and Arkshine committed Jul 18, 2018
1 parent fba3d70 commit 98ab266
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions amxmodx/newmenus.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions amxmodx/newmenus.h
Expand Up @@ -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);

Expand Down Expand Up @@ -125,6 +126,7 @@ class Menu
int func;
bool isDestroying;
int pageCallback;
bool showPageNumber;
public:
unsigned int items_per_page;
};
Expand Down
5 changes: 5 additions & 0 deletions plugins/include/newmenus.inc
Expand Up @@ -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
*/
Expand Down

0 comments on commit 98ab266

Please sign in to comment.