diff --git a/core/MenuManager.cpp b/core/MenuManager.cpp index 051b7b7f..f5eb9d87 100644 --- a/core/MenuManager.cpp +++ b/core/MenuManager.cpp @@ -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; diff --git a/core/smn_menus.cpp b/core/smn_menus.cpp index ffb1a4a8..9aa856da 100644 --- a/core/smn_menus.cpp +++ b/core/smn_menus.cpp @@ -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}, }; diff --git a/public/IMenuManager.h b/public/IMenuManager.h index 4717404d..ca9857ca 100644 --- a/public/IMenuManager.h +++ b/public/IMenuManager.h @@ -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 */ diff --git a/translations/core.phrases.txt b/translations/core.phrases.txt index cea22c50..0e241b41 100644 --- a/translations/core.phrases.txt +++ b/translations/core.phrases.txt @@ -72,6 +72,11 @@ "#format" "{1:s},{2:s}" "en" "{1} changed their vote to {2}" } + + "No Vote" + { + "en" "No Vote" + } /* This is a special "pass-thru" translation */ "_s"