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:
+36
-15
@@ -285,9 +285,13 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
MenuEndReason end_reason = MenuEnd_Selected;
|
||||
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;
|
||||
} 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;
|
||||
|
||||
/* 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;
|
||||
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 */
|
||||
player->bInMenu = false;
|
||||
if (player->menuHoldTime)
|
||||
@@ -581,10 +582,10 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
||||
}
|
||||
|
||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||
m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_ExitButton(true),
|
||||
m_bShouldDelete(false), m_bCancelling(false), m_pOwner(pOwner ? pOwner : g_pCoreIdent),
|
||||
m_bDeleting(false), m_bWillFreeHandle(false), m_hHandle(BAD_HANDLE), m_pHandler(pHandler),
|
||||
m_pVoteHandler(NULL), m_ExitBackButton(false)
|
||||
m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||
m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_pVoteHandler(NULL),
|
||||
m_nFlags(MENUFLAG_BUTTON_EXIT)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -733,12 +734,17 @@ const char *CBaseMenu::GetDefaultTitle()
|
||||
|
||||
bool CBaseMenu::GetExitButton()
|
||||
{
|
||||
return m_ExitButton;
|
||||
return ((m_nFlags & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT);
|
||||
}
|
||||
|
||||
bool CBaseMenu::SetExitButton(bool set)
|
||||
{
|
||||
m_ExitButton = set;
|
||||
if (set)
|
||||
{
|
||||
m_nFlags |= MENUFLAG_BUTTON_EXIT;
|
||||
} else {
|
||||
m_nFlags &= ~MENUFLAG_BUTTON_EXIT;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -860,10 +866,25 @@ bool CBaseMenu::IsVoteInProgress()
|
||||
|
||||
bool CBaseMenu::GetExitBackButton()
|
||||
{
|
||||
return m_ExitBackButton;
|
||||
return ((m_nFlags & MENUFLAG_BUTTON_EXITBACK) == MENUFLAG_BUTTON_EXITBACK);
|
||||
}
|
||||
|
||||
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 GetExitBackButton();
|
||||
virtual void SetExitBackButton(bool set);
|
||||
virtual unsigned int GetMenuOptionFlags();
|
||||
virtual void SetMenuOptionFlags(unsigned int flags);
|
||||
public:
|
||||
virtual void VoteDisplay(int client, unsigned int maxTime) =0;
|
||||
private:
|
||||
@@ -148,7 +150,6 @@ protected:
|
||||
BaseStringTable m_Strings;
|
||||
unsigned int m_Pagination;
|
||||
CVector<CItem> m_items;
|
||||
bool m_ExitButton;
|
||||
bool m_bShouldDelete;
|
||||
bool m_bCancelling;
|
||||
IdentityToken_t *m_pOwner;
|
||||
@@ -157,7 +158,7 @@ protected:
|
||||
Handle_t m_hHandle;
|
||||
IMenuHandler *m_pHandler;
|
||||
IVoteMenuHandler *m_pVoteHandler;
|
||||
bool m_ExitBackButton;
|
||||
unsigned int m_nFlags;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_MENUSTYLE_BASE_H
|
||||
|
||||
@@ -418,6 +418,12 @@ bool CValveMenu::SetExitButton(bool set)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CValveMenu::SetMenuOptionFlags(unsigned int flags)
|
||||
{
|
||||
flags &= ~MENUFLAG_BUTTON_EXIT;
|
||||
CBaseMenu::SetMenuOptionFlags(flags);
|
||||
}
|
||||
|
||||
const char *g_OptionNumTable[] =
|
||||
{
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
|
||||
|
||||
@@ -122,6 +122,7 @@ public: //IBaseMenu
|
||||
bool SetPagination(unsigned int itemsPerPage);
|
||||
bool Display(int client, unsigned int time);
|
||||
void VoteDisplay(int client, unsigned int maxTime);
|
||||
void SetMenuOptionFlags(unsigned int flags);
|
||||
public: //CBaseMenu
|
||||
void Cancel_Finally();
|
||||
private:
|
||||
|
||||
@@ -1092,6 +1092,36 @@ static cell_t RedrawMenuItem(IPluginContext *pContext, const cell_t *params)
|
||||
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)
|
||||
{
|
||||
{"AddMenuItem", AddMenuItem},
|
||||
@@ -1111,6 +1141,7 @@ REGISTER_NATIVES(menuNatives)
|
||||
{"GetMenuExitButton", GetMenuExitButton},
|
||||
{"GetMenuItem", GetMenuItem},
|
||||
{"GetMenuItemCount", GetMenuItemCount},
|
||||
{"GetMenuOptionFlags", GetMenuOptionFlags},
|
||||
{"GetMenuPagination", GetMenuPagination},
|
||||
{"GetMenuStyle", GetMenuStyle},
|
||||
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
||||
@@ -1124,6 +1155,7 @@ REGISTER_NATIVES(menuNatives)
|
||||
{"SendPanelToClient", SendPanelToClient},
|
||||
{"SetMenuExitBackButton", SetMenuExitBackButton},
|
||||
{"SetMenuExitButton", SetMenuExitButton},
|
||||
{"SetMenuOptionFlags", SetMenuOptionFlags},
|
||||
{"SetMenuPagination", SetMenuPagination},
|
||||
{"SetMenuTitle", SetMenuTitle},
|
||||
{"SetPanelCurrentKey", SetPanelCurrentKey},
|
||||
|
||||
Reference in New Issue
Block a user