implemented amb705 (you can now disable sounds per-menu)
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401265
This commit is contained in:
parent
e37a7bcbbe
commit
70f22ab3ab
@ -285,9 +285,13 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
MenuEndReason end_reason = MenuEnd_Selected;
|
MenuEndReason end_reason = MenuEnd_Selected;
|
||||||
menu_states_t &states = player->states;
|
menu_states_t &states = player->states;
|
||||||
|
|
||||||
assert(states.mh != NULL);
|
/* Save variables */
|
||||||
|
IMenuHandler *mh = states.mh;
|
||||||
|
IBaseMenu *menu = states.menu;
|
||||||
|
|
||||||
if (states.menu == NULL)
|
assert(mh != NULL);
|
||||||
|
|
||||||
|
if (menu == NULL)
|
||||||
{
|
{
|
||||||
item = key_press;
|
item = key_press;
|
||||||
} else if (key_press < 1 || key_press > GetMaxPageItems()) {
|
} else if (key_press < 1 || key_press > GetMaxPageItems()) {
|
||||||
@ -296,7 +300,8 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
ItemSelection type = states.slots[key_press].type;
|
ItemSelection type = states.slots[key_press].type;
|
||||||
|
|
||||||
/* Check if we should play a sound about the type */
|
/* Check if we should play a sound about the type */
|
||||||
if (g_Menus.MenuSoundsEnabled())
|
if (g_Menus.MenuSoundsEnabled() &&
|
||||||
|
(!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND))
|
||||||
{
|
{
|
||||||
CellRecipientFilter filter;
|
CellRecipientFilter filter;
|
||||||
cell_t clients[1];
|
cell_t clients[1];
|
||||||
@ -364,10 +369,6 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save variables */
|
|
||||||
IMenuHandler *mh = states.mh;
|
|
||||||
IBaseMenu *menu = states.menu;
|
|
||||||
|
|
||||||
/* Clear states */
|
/* Clear states */
|
||||||
player->bInMenu = false;
|
player->bInMenu = false;
|
||||||
if (player->menuHoldTime)
|
if (player->menuHoldTime)
|
||||||
@ -581,10 +582,10 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||||
m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_ExitButton(true),
|
m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||||
m_bShouldDelete(false), m_bCancelling(false), m_pOwner(pOwner ? pOwner : g_pCoreIdent),
|
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||||
m_bDeleting(false), m_bWillFreeHandle(false), m_hHandle(BAD_HANDLE), m_pHandler(pHandler),
|
m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_pVoteHandler(NULL),
|
||||||
m_pVoteHandler(NULL), m_ExitBackButton(false)
|
m_nFlags(MENUFLAG_BUTTON_EXIT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,12 +734,17 @@ const char *CBaseMenu::GetDefaultTitle()
|
|||||||
|
|
||||||
bool CBaseMenu::GetExitButton()
|
bool CBaseMenu::GetExitButton()
|
||||||
{
|
{
|
||||||
return m_ExitButton;
|
return ((m_nFlags & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBaseMenu::SetExitButton(bool set)
|
bool CBaseMenu::SetExitButton(bool set)
|
||||||
{
|
{
|
||||||
m_ExitButton = set;
|
if (set)
|
||||||
|
{
|
||||||
|
m_nFlags |= MENUFLAG_BUTTON_EXIT;
|
||||||
|
} else {
|
||||||
|
m_nFlags &= ~MENUFLAG_BUTTON_EXIT;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,10 +866,25 @@ bool CBaseMenu::IsVoteInProgress()
|
|||||||
|
|
||||||
bool CBaseMenu::GetExitBackButton()
|
bool CBaseMenu::GetExitBackButton()
|
||||||
{
|
{
|
||||||
return m_ExitBackButton;
|
return ((m_nFlags & MENUFLAG_BUTTON_EXITBACK) == MENUFLAG_BUTTON_EXITBACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseMenu::SetExitBackButton(bool set)
|
void CBaseMenu::SetExitBackButton(bool set)
|
||||||
{
|
{
|
||||||
m_ExitBackButton = set;
|
if (set)
|
||||||
|
{
|
||||||
|
m_nFlags |= MENUFLAG_BUTTON_EXITBACK;
|
||||||
|
} else {
|
||||||
|
m_nFlags &= ~MENUFLAG_BUTTON_EXITBACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CBaseMenu::GetMenuOptionFlags()
|
||||||
|
{
|
||||||
|
return m_nFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseMenu::SetMenuOptionFlags(unsigned int flags)
|
||||||
|
{
|
||||||
|
m_nFlags = flags;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +138,8 @@ public:
|
|||||||
virtual bool IsVoteInProgress();
|
virtual bool IsVoteInProgress();
|
||||||
virtual bool GetExitBackButton();
|
virtual bool GetExitBackButton();
|
||||||
virtual void SetExitBackButton(bool set);
|
virtual void SetExitBackButton(bool set);
|
||||||
|
virtual unsigned int GetMenuOptionFlags();
|
||||||
|
virtual void SetMenuOptionFlags(unsigned int flags);
|
||||||
public:
|
public:
|
||||||
virtual void VoteDisplay(int client, unsigned int maxTime) =0;
|
virtual void VoteDisplay(int client, unsigned int maxTime) =0;
|
||||||
private:
|
private:
|
||||||
@ -148,7 +150,6 @@ protected:
|
|||||||
BaseStringTable m_Strings;
|
BaseStringTable m_Strings;
|
||||||
unsigned int m_Pagination;
|
unsigned int m_Pagination;
|
||||||
CVector<CItem> m_items;
|
CVector<CItem> m_items;
|
||||||
bool m_ExitButton;
|
|
||||||
bool m_bShouldDelete;
|
bool m_bShouldDelete;
|
||||||
bool m_bCancelling;
|
bool m_bCancelling;
|
||||||
IdentityToken_t *m_pOwner;
|
IdentityToken_t *m_pOwner;
|
||||||
@ -157,7 +158,7 @@ protected:
|
|||||||
Handle_t m_hHandle;
|
Handle_t m_hHandle;
|
||||||
IMenuHandler *m_pHandler;
|
IMenuHandler *m_pHandler;
|
||||||
IVoteMenuHandler *m_pVoteHandler;
|
IVoteMenuHandler *m_pVoteHandler;
|
||||||
bool m_ExitBackButton;
|
unsigned int m_nFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_MENUSTYLE_BASE_H
|
#endif //_INCLUDE_MENUSTYLE_BASE_H
|
||||||
|
@ -418,6 +418,12 @@ bool CValveMenu::SetExitButton(bool set)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CValveMenu::SetMenuOptionFlags(unsigned int flags)
|
||||||
|
{
|
||||||
|
flags &= ~MENUFLAG_BUTTON_EXIT;
|
||||||
|
CBaseMenu::SetMenuOptionFlags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
const char *g_OptionNumTable[] =
|
const char *g_OptionNumTable[] =
|
||||||
{
|
{
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
|
||||||
|
@ -122,6 +122,7 @@ public: //IBaseMenu
|
|||||||
bool SetPagination(unsigned int itemsPerPage);
|
bool SetPagination(unsigned int itemsPerPage);
|
||||||
bool Display(int client, unsigned int time);
|
bool Display(int client, unsigned int time);
|
||||||
void VoteDisplay(int client, unsigned int maxTime);
|
void VoteDisplay(int client, unsigned int maxTime);
|
||||||
|
void SetMenuOptionFlags(unsigned int flags);
|
||||||
public: //CBaseMenu
|
public: //CBaseMenu
|
||||||
void Cancel_Finally();
|
void Cancel_Finally();
|
||||||
private:
|
private:
|
||||||
|
@ -1092,6 +1092,36 @@ static cell_t RedrawMenuItem(IPluginContext *pContext, const cell_t *params)
|
|||||||
return s_CurPanelReturn;
|
return s_CurPanelReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t GetMenuOptionFlags(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return menu->GetMenuOptionFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t SetMenuOptionFlags(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->SetMenuOptionFlags(params[2]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(menuNatives)
|
REGISTER_NATIVES(menuNatives)
|
||||||
{
|
{
|
||||||
{"AddMenuItem", AddMenuItem},
|
{"AddMenuItem", AddMenuItem},
|
||||||
@ -1111,6 +1141,7 @@ REGISTER_NATIVES(menuNatives)
|
|||||||
{"GetMenuExitButton", GetMenuExitButton},
|
{"GetMenuExitButton", GetMenuExitButton},
|
||||||
{"GetMenuItem", GetMenuItem},
|
{"GetMenuItem", GetMenuItem},
|
||||||
{"GetMenuItemCount", GetMenuItemCount},
|
{"GetMenuItemCount", GetMenuItemCount},
|
||||||
|
{"GetMenuOptionFlags", GetMenuOptionFlags},
|
||||||
{"GetMenuPagination", GetMenuPagination},
|
{"GetMenuPagination", GetMenuPagination},
|
||||||
{"GetMenuStyle", GetMenuStyle},
|
{"GetMenuStyle", GetMenuStyle},
|
||||||
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
||||||
@ -1124,6 +1155,7 @@ REGISTER_NATIVES(menuNatives)
|
|||||||
{"SendPanelToClient", SendPanelToClient},
|
{"SendPanelToClient", SendPanelToClient},
|
||||||
{"SetMenuExitBackButton", SetMenuExitBackButton},
|
{"SetMenuExitBackButton", SetMenuExitBackButton},
|
||||||
{"SetMenuExitButton", SetMenuExitButton},
|
{"SetMenuExitButton", SetMenuExitButton},
|
||||||
|
{"SetMenuOptionFlags", SetMenuOptionFlags},
|
||||||
{"SetMenuPagination", SetMenuPagination},
|
{"SetMenuPagination", SetMenuPagination},
|
||||||
{"SetMenuTitle", SetMenuTitle},
|
{"SetMenuTitle", SetMenuTitle},
|
||||||
{"SetPanelCurrentKey", SetPanelCurrentKey},
|
{"SetPanelCurrentKey", SetPanelCurrentKey},
|
||||||
|
@ -64,6 +64,10 @@ enum MenuAction
|
|||||||
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
|
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
|
||||||
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
|
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reasons a menu can be cancelled.
|
* Reasons a menu can be cancelled.
|
||||||
*/
|
*/
|
||||||
@ -324,6 +328,28 @@ native SetMenuExitBackButton(Handle:menu, bool:button);
|
|||||||
*/
|
*/
|
||||||
native CancelMenu(Handle:menu);
|
native CancelMenu(Handle:menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a menu's option flags.
|
||||||
|
*
|
||||||
|
* @param menu Menu Handle.
|
||||||
|
* @return A bitstring of MENUFLAG bits.
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native GetMenuOptionFlags(Handle:menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a menu's option flags.
|
||||||
|
*
|
||||||
|
* If a certain bit is not supported, it will be stripped before
|
||||||
|
* being set.
|
||||||
|
*
|
||||||
|
* @param menu Menu Handle.
|
||||||
|
* @param flags A new bitstring of MENUFLAG bits.
|
||||||
|
* @noreturn
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native SetMenuOptionFlags(Handle:menu, flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a vote is in progress on the given menu.
|
* Returns whether a vote is in progress on the given menu.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
|
|
||||||
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
||||||
#define SMINTERFACE_MENUMANAGER_VERSION 7
|
#define SMINTERFACE_MENUMANAGER_VERSION 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file IMenuManager.h
|
* @file IMenuManager.h
|
||||||
@ -147,6 +147,10 @@ namespace SourceMod
|
|||||||
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
|
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
|
||||||
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
|
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extended menu options.
|
* @brief Extended menu options.
|
||||||
*/
|
*/
|
||||||
@ -567,6 +571,20 @@ namespace SourceMod
|
|||||||
* @param set True to enable, false to disable.
|
* @param set True to enable, false to disable.
|
||||||
*/
|
*/
|
||||||
virtual void SetExitBackButton(bool set) =0;
|
virtual void SetExitBackButton(bool set) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns menu option flags.
|
||||||
|
*
|
||||||
|
* @return Menu option flags.
|
||||||
|
*/
|
||||||
|
virtual unsigned int GetMenuOptionFlags() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets menu option flags.
|
||||||
|
*
|
||||||
|
* @param flags Menu option flags.
|
||||||
|
*/
|
||||||
|
virtual void SetMenuOptionFlags(unsigned int flags) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user