Added optional 'No Vote' option to vote menu (bug 4217, r=dvander)
This commit is contained in:
parent
46a46f5e49
commit
5f9b2a91fd
@ -231,6 +231,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
|
||||
unsigned int pgn = menu->GetPagination();
|
||||
unsigned int maxItems = style->GetMaxPageItems();
|
||||
bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT;
|
||||
bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE;
|
||||
|
||||
if (pgn != MENU_NO_PAGINATION)
|
||||
{
|
||||
@ -241,6 +242,11 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
|
||||
maxItems--;
|
||||
}
|
||||
|
||||
if (novoteButton)
|
||||
{
|
||||
maxItems--;
|
||||
}
|
||||
|
||||
/* This is very not allowed! */
|
||||
if (maxItems < 2)
|
||||
{
|
||||
@ -436,6 +442,20 @@ skip_search:
|
||||
/* Draw the item according to the order */
|
||||
menu_slots_t *slots = md.slots;
|
||||
unsigned int position = 0; /* Keep track of the last position */
|
||||
|
||||
if (novoteButton)
|
||||
{
|
||||
char text[50];
|
||||
if (!CoreTranslate(text, sizeof(text), "%T", 2, NULL, "No Vote", &client))
|
||||
{
|
||||
UTIL_Format(text, sizeof(text), "No Vote");
|
||||
}
|
||||
ItemDrawInfo dr(text, 0);
|
||||
position = panel->DrawItem(dr);
|
||||
slots[position].type = ItemSel_Exit;
|
||||
position++;
|
||||
}
|
||||
|
||||
if (order == ItemOrder_Ascending)
|
||||
{
|
||||
md.item_on_page = drawItems[0].position;
|
||||
|
@ -948,6 +948,32 @@ static cell_t SetMenuExitButton(IPluginContext *pContext, const cell_t *params)
|
||||
return (flags == new_flags);
|
||||
}
|
||||
|
||||
static cell_t SetMenuNoVoteButton(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = (Handle_t)params[1];
|
||||
HandleError err;
|
||||
IBaseMenu *menu;
|
||||
|
||||
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
unsigned int flags = menu->GetMenuOptionFlags();
|
||||
|
||||
if (params[2])
|
||||
{
|
||||
flags |= MENUFLAG_BUTTON_NOVOTE;
|
||||
} else {
|
||||
flags &= ~MENUFLAG_BUTTON_NOVOTE;
|
||||
}
|
||||
|
||||
menu->SetMenuOptionFlags(flags);
|
||||
unsigned int new_flags = menu->GetMenuOptionFlags();
|
||||
|
||||
return (flags == new_flags);
|
||||
}
|
||||
|
||||
static cell_t SetMenuExitBackButton(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = (Handle_t)params[1];
|
||||
@ -1577,6 +1603,7 @@ REGISTER_NATIVES(menuNatives)
|
||||
{"SetPanelKeys", SetPanelKeys},
|
||||
{"SetVoteResultCallback", SetVoteResultCallback},
|
||||
{"VoteMenu", VoteMenu},
|
||||
{"SetMenuNoVoteButton", SetMenuNoVoteButton},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
@ -178,6 +178,7 @@ namespace SourceMod
|
||||
#define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button */
|
||||
#define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
|
||||
#define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
|
||||
#define MENUFLAG_BUTTON_NOVOTE (1<<3) /**< Menu has a "No Vote" button at slot 1 */
|
||||
|
||||
#define VOTEFLAG_NO_REVOTES (1<<0) /**< Players cannot change their votes */
|
||||
|
||||
|
@ -73,6 +73,11 @@
|
||||
"en" "{1} changed their vote to {2}"
|
||||
}
|
||||
|
||||
"No Vote"
|
||||
{
|
||||
"en" "No Vote"
|
||||
}
|
||||
|
||||
/* This is a special "pass-thru" translation */
|
||||
"_s"
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user