mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added menu property to change number color
This commit is contained in:
parent
51f8d7f84e
commit
1ed1d0005c
@ -90,6 +90,7 @@ Menu::Menu(const char *title, int mid, int tid)
|
|||||||
m_OptNames[abs(MENU_MORE)].assign("More");
|
m_OptNames[abs(MENU_MORE)].assign("More");
|
||||||
m_OptNames[abs(MENU_EXIT)].assign("Exit");
|
m_OptNames[abs(MENU_EXIT)].assign("Exit");
|
||||||
|
|
||||||
|
m_ItemColor.assign("\\r");
|
||||||
m_NeverExit = false;
|
m_NeverExit = false;
|
||||||
m_AutoColors = g_coloredmenus;
|
m_AutoColors = g_coloredmenus;
|
||||||
|
|
||||||
@ -392,7 +393,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
{
|
{
|
||||||
if (m_AutoColors)
|
if (m_AutoColors)
|
||||||
{
|
{
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "\\r%d.\\w %s\n", option_display, pItem->name.c_str());
|
_snprintf(buffer, sizeof(buffer)-1, "%s%d.\\w %s\n", m_ItemColor.c_str(),option_display, pItem->name.c_str());
|
||||||
} else {
|
} else {
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option_display, pItem->name.c_str());
|
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option_display, pItem->name.c_str());
|
||||||
}
|
}
|
||||||
@ -440,11 +441,21 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
if (flags & Display_Back)
|
if (flags & Display_Back)
|
||||||
{
|
{
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
_snprintf(buffer,
|
if (m_AutoColors)
|
||||||
sizeof(buffer)-1,
|
{
|
||||||
m_AutoColors ? "\\r%d. \\w%s\n" : "%d. %s\n",
|
_snprintf(buffer,
|
||||||
option == 10 ? 0 : option,
|
sizeof(buffer)-1,
|
||||||
m_OptNames[abs(MENU_BACK)].c_str());
|
"%s%d. \\w%s\n",
|
||||||
|
m_ItemColor.c_str(),
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_BACK)].c_str());
|
||||||
|
} else {
|
||||||
|
_snprintf(buffer,
|
||||||
|
sizeof(buffer)-1,
|
||||||
|
"%d. %s\n",
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_BACK)].c_str());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
option++;
|
option++;
|
||||||
if (m_AutoColors)
|
if (m_AutoColors)
|
||||||
@ -463,11 +474,21 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
if (flags & Display_Next)
|
if (flags & Display_Next)
|
||||||
{
|
{
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
_snprintf(buffer,
|
if (m_AutoColors)
|
||||||
sizeof(buffer)-1,
|
{
|
||||||
m_AutoColors ? "\\r%d. \\w%s\n" : "%d. %s\n",
|
_snprintf(buffer,
|
||||||
option == 10 ? 0 : option,
|
sizeof(buffer)-1,
|
||||||
m_OptNames[abs(MENU_MORE)].c_str());
|
"%s%d. \\w%s\n",
|
||||||
|
m_ItemColor.c_str(),
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_MORE)].c_str());
|
||||||
|
} else {
|
||||||
|
_snprintf(buffer,
|
||||||
|
sizeof(buffer)-1,
|
||||||
|
"%d. %s\n",
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_MORE)].c_str());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
option++;
|
option++;
|
||||||
if (m_AutoColors)
|
if (m_AutoColors)
|
||||||
@ -490,11 +511,21 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
if (!m_NeverExit)
|
if (!m_NeverExit)
|
||||||
{
|
{
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
_snprintf(buffer,
|
if (m_AutoColors)
|
||||||
sizeof(buffer)-1,
|
{
|
||||||
m_AutoColors ? "\\r%d. \\w%s\n" : "%d. %s\n",
|
_snprintf(buffer,
|
||||||
option == 10 ? 0 : option,
|
sizeof(buffer)-1,
|
||||||
m_OptNames[abs(MENU_EXIT)].c_str());
|
"%s%d. \\w%s\n",
|
||||||
|
m_ItemColor.c_str(),
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_EXIT)].c_str());
|
||||||
|
} else {
|
||||||
|
_snprintf(buffer,
|
||||||
|
sizeof(buffer)-1,
|
||||||
|
"%d. %s\n",
|
||||||
|
option == 10 ? 0 : option,
|
||||||
|
m_OptNames[abs(MENU_EXIT)].c_str());
|
||||||
|
}
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,6 +812,13 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params)
|
|||||||
|
|
||||||
switch (params[2])
|
switch (params[2])
|
||||||
{
|
{
|
||||||
|
case MPROP_SET_NUMBER_COLOR:
|
||||||
|
{
|
||||||
|
char *str = get_amxstring(amx, params[3], 0, len);
|
||||||
|
validate_menu_text(str);
|
||||||
|
pMenu->m_ItemColor.assign(str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MPROP_PERPAGE:
|
case MPROP_PERPAGE:
|
||||||
{
|
{
|
||||||
cell count = *get_amxaddr(amx, params[3]);
|
cell count = *get_amxaddr(amx, params[3]);
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#define MPROP_ORDER 7
|
#define MPROP_ORDER 7
|
||||||
#define MPROP_NOCOLORS 8
|
#define MPROP_NOCOLORS 8
|
||||||
#define MPROP_PADMENU 9
|
#define MPROP_PADMENU 9
|
||||||
|
#define MPROP_SET_NUMBER_COLOR 10
|
||||||
|
|
||||||
typedef int (*MENUITEM_CALLBACK)(int, int, int);
|
typedef int (*MENUITEM_CALLBACK)(int, int, int);
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ public:
|
|||||||
|
|
||||||
String m_OptNames[4];
|
String m_OptNames[4];
|
||||||
|
|
||||||
|
String m_ItemColor;
|
||||||
bool m_NeverExit;
|
bool m_NeverExit;
|
||||||
bool m_AutoColors;
|
bool m_AutoColors;
|
||||||
|
|
||||||
|
@ -296,6 +296,7 @@ enum {
|
|||||||
#define MPROP_ORDER 7 /* Deprecated, has no effect */
|
#define MPROP_ORDER 7 /* Deprecated, has no effect */
|
||||||
#define MPROP_NOCOLORS 8 //NUM - sets whether colors are not auto (0=default)
|
#define MPROP_NOCOLORS 8 //NUM - sets whether colors are not auto (0=default)
|
||||||
#define MPROP_PADMENU 9 /* Deprecated, has no effect */
|
#define MPROP_PADMENU 9 /* Deprecated, has no effect */
|
||||||
|
#define MPROP_NUMBER_COLOR 10 //STRING - color indicator to use for the numbers. ("\r"=default)
|
||||||
|
|
||||||
#define SND_SPAWNING (1<<8) // we're spawing, used in some cases for ambients
|
#define SND_SPAWNING (1<<8) // we're spawing, used in some cases for ambients
|
||||||
#define SND_STOP (1<<5) // stop sound
|
#define SND_STOP (1<<5) // stop sound
|
||||||
|
Loading…
Reference in New Issue
Block a user