1.1 --- a/core/MenuStyle_Base.cpp Fri Aug 03 11:14:56 2007 +0000
1.2 +++ b/core/MenuStyle_Base.cpp Fri Aug 03 11:40:21 2007 +0000
1.3 @@ -285,9 +285,13 @@
1.4 MenuEndReason end_reason = MenuEnd_Selected;
1.5 menu_states_t &states = player->states;
1.6
1.7 - assert(states.mh != NULL);
1.8 + /* Save variables */
1.9 + IMenuHandler *mh = states.mh;
1.10 + IBaseMenu *menu = states.menu;
1.11
1.12 - if (states.menu == NULL)
1.13 + assert(mh != NULL);
1.14 +
1.15 + if (menu == NULL)
1.16 {
1.17 item = key_press;
1.18 } else if (key_press < 1 || key_press > GetMaxPageItems()) {
1.19 @@ -296,7 +300,8 @@
1.20 ItemSelection type = states.slots[key_press].type;
1.21
1.22 /* Check if we should play a sound about the type */
1.23 - if (g_Menus.MenuSoundsEnabled())
1.24 + if (g_Menus.MenuSoundsEnabled() &&
1.25 + (!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND))
1.26 {
1.27 CellRecipientFilter filter;
1.28 cell_t clients[1];
1.29 @@ -364,10 +369,6 @@
1.30 }
1.31 }
1.32
1.33 - /* Save variables */
1.34 - IMenuHandler *mh = states.mh;
1.35 - IBaseMenu *menu = states.menu;
1.36 -
1.37 /* Clear states */
1.38 player->bInMenu = false;
1.39 if (player->menuHoldTime)
1.40 @@ -581,10 +582,10 @@
1.41 }
1.42
1.43 CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
1.44 -m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_ExitButton(true),
1.45 -m_bShouldDelete(false), m_bCancelling(false), m_pOwner(pOwner ? pOwner : g_pCoreIdent),
1.46 -m_bDeleting(false), m_bWillFreeHandle(false), m_hHandle(BAD_HANDLE), m_pHandler(pHandler),
1.47 -m_pVoteHandler(NULL), m_ExitBackButton(false)
1.48 +m_pStyle(pStyle), m_Strings(512), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
1.49 +m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
1.50 +m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_pVoteHandler(NULL),
1.51 +m_nFlags(MENUFLAG_BUTTON_EXIT)
1.52 {
1.53 }
1.54
1.55 @@ -733,12 +734,17 @@
1.56
1.57 bool CBaseMenu::GetExitButton()
1.58 {
1.59 - return m_ExitButton;
1.60 + return ((m_nFlags & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT);
1.61 }
1.62
1.63 bool CBaseMenu::SetExitButton(bool set)
1.64 {
1.65 - m_ExitButton = set;
1.66 + if (set)
1.67 + {
1.68 + m_nFlags |= MENUFLAG_BUTTON_EXIT;
1.69 + } else {
1.70 + m_nFlags &= ~MENUFLAG_BUTTON_EXIT;
1.71 + }
1.72 return true;
1.73 }
1.74
1.75 @@ -860,10 +866,25 @@
1.76
1.77 bool CBaseMenu::GetExitBackButton()
1.78 {
1.79 - return m_ExitBackButton;
1.80 + return ((m_nFlags & MENUFLAG_BUTTON_EXITBACK) == MENUFLAG_BUTTON_EXITBACK);
1.81 }
1.82
1.83 void CBaseMenu::SetExitBackButton(bool set)
1.84 {
1.85 - m_ExitBackButton = set;
1.86 + if (set)
1.87 + {
1.88 + m_nFlags |= MENUFLAG_BUTTON_EXITBACK;
1.89 + } else {
1.90 + m_nFlags &= ~MENUFLAG_BUTTON_EXITBACK;
1.91 + }
1.92 }
1.93 +
1.94 +unsigned int CBaseMenu::GetMenuOptionFlags()
1.95 +{
1.96 + return m_nFlags;
1.97 +}
1.98 +
1.99 +void CBaseMenu::SetMenuOptionFlags(unsigned int flags)
1.100 +{
1.101 + m_nFlags = flags;
1.102 +}
2.1 --- a/core/MenuStyle_Base.h Fri Aug 03 11:14:56 2007 +0000
2.2 +++ b/core/MenuStyle_Base.h Fri Aug 03 11:40:21 2007 +0000
2.3 @@ -138,6 +138,8 @@
2.4 virtual bool IsVoteInProgress();
2.5 virtual bool GetExitBackButton();
2.6 virtual void SetExitBackButton(bool set);
2.7 + virtual unsigned int GetMenuOptionFlags();
2.8 + virtual void SetMenuOptionFlags(unsigned int flags);
2.9 public:
2.10 virtual void VoteDisplay(int client, unsigned int maxTime) =0;
2.11 private:
2.12 @@ -148,7 +150,6 @@
2.13 BaseStringTable m_Strings;
2.14 unsigned int m_Pagination;
2.15 CVector<CItem> m_items;
2.16 - bool m_ExitButton;
2.17 bool m_bShouldDelete;
2.18 bool m_bCancelling;
2.19 IdentityToken_t *m_pOwner;
2.20 @@ -157,7 +158,7 @@
2.21 Handle_t m_hHandle;
2.22 IMenuHandler *m_pHandler;
2.23 IVoteMenuHandler *m_pVoteHandler;
2.24 - bool m_ExitBackButton;
2.25 + unsigned int m_nFlags;
2.26 };
2.27
2.28 #endif //_INCLUDE_MENUSTYLE_BASE_H
3.1 --- a/core/MenuStyle_Valve.cpp Fri Aug 03 11:14:56 2007 +0000
3.2 +++ b/core/MenuStyle_Valve.cpp Fri Aug 03 11:40:21 2007 +0000
3.3 @@ -418,6 +418,12 @@
3.4 return false;
3.5 }
3.6
3.7 +void CValveMenu::SetMenuOptionFlags(unsigned int flags)
3.8 +{
3.9 + flags &= ~MENUFLAG_BUTTON_EXIT;
3.10 + CBaseMenu::SetMenuOptionFlags(flags);
3.11 +}
3.12 +
3.13 const char *g_OptionNumTable[] =
3.14 {
3.15 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
4.1 --- a/core/MenuStyle_Valve.h Fri Aug 03 11:14:56 2007 +0000
4.2 +++ b/core/MenuStyle_Valve.h Fri Aug 03 11:40:21 2007 +0000
4.3 @@ -122,6 +122,7 @@
4.4 bool SetPagination(unsigned int itemsPerPage);
4.5 bool Display(int client, unsigned int time);
4.6 void VoteDisplay(int client, unsigned int maxTime);
4.7 + void SetMenuOptionFlags(unsigned int flags);
4.8 public: //CBaseMenu
4.9 void Cancel_Finally();
4.10 private:
5.1 --- a/core/smn_menus.cpp Fri Aug 03 11:14:56 2007 +0000
5.2 +++ b/core/smn_menus.cpp Fri Aug 03 11:40:21 2007 +0000
5.3 @@ -1092,6 +1092,36 @@
5.4 return s_CurPanelReturn;
5.5 }
5.6
5.7 +static cell_t GetMenuOptionFlags(IPluginContext *pContext, const cell_t *params)
5.8 +{
5.9 + Handle_t hndl = (Handle_t)params[1];
5.10 + HandleError err;
5.11 + IBaseMenu *menu;
5.12 +
5.13 + if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
5.14 + {
5.15 + return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
5.16 + }
5.17 +
5.18 + return menu->GetMenuOptionFlags();
5.19 +}
5.20 +
5.21 +static cell_t SetMenuOptionFlags(IPluginContext *pContext, const cell_t *params)
5.22 +{
5.23 + Handle_t hndl = (Handle_t)params[1];
5.24 + HandleError err;
5.25 + IBaseMenu *menu;
5.26 +
5.27 + if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
5.28 + {
5.29 + return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
5.30 + }
5.31 +
5.32 + menu->SetMenuOptionFlags(params[2]);
5.33 +
5.34 + return 1;
5.35 +}
5.36 +
5.37 REGISTER_NATIVES(menuNatives)
5.38 {
5.39 {"AddMenuItem", AddMenuItem},
5.40 @@ -1111,6 +1141,7 @@
5.41 {"GetMenuExitButton", GetMenuExitButton},
5.42 {"GetMenuItem", GetMenuItem},
5.43 {"GetMenuItemCount", GetMenuItemCount},
5.44 + {"GetMenuOptionFlags", GetMenuOptionFlags},
5.45 {"GetMenuPagination", GetMenuPagination},
5.46 {"GetMenuStyle", GetMenuStyle},
5.47 {"GetMenuStyleHandle", GetMenuStyleHandle},
5.48 @@ -1124,6 +1155,7 @@
5.49 {"SendPanelToClient", SendPanelToClient},
5.50 {"SetMenuExitBackButton", SetMenuExitBackButton},
5.51 {"SetMenuExitButton", SetMenuExitButton},
5.52 + {"SetMenuOptionFlags", SetMenuOptionFlags},
5.53 {"SetMenuPagination", SetMenuPagination},
5.54 {"SetMenuTitle", SetMenuTitle},
5.55 {"SetPanelCurrentKey", SetPanelCurrentKey},
6.1 --- a/plugins/include/menus.inc Fri Aug 03 11:14:56 2007 +0000
6.2 +++ b/plugins/include/menus.inc Fri Aug 03 11:40:21 2007 +0000
6.3 @@ -64,6 +64,10 @@
6.4 #define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
6.5 #define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
6.6
6.7 +#define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button */
6.8 +#define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
6.9 +#define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
6.10 +
6.11 /**
6.12 * Reasons a menu can be cancelled.
6.13 */
6.14 @@ -325,6 +329,28 @@
6.15 native CancelMenu(Handle:menu);
6.16
6.17 /**
6.18 + * Retrieves a menu's option flags.
6.19 + *
6.20 + * @param menu Menu Handle.
6.21 + * @return A bitstring of MENUFLAG bits.
6.22 + * @error Invalid Handle.
6.23 + */
6.24 +native GetMenuOptionFlags(Handle:menu);
6.25 +
6.26 +/**
6.27 + * Sets a menu's option flags.
6.28 + *
6.29 + * If a certain bit is not supported, it will be stripped before
6.30 + * being set.
6.31 + *
6.32 + * @param menu Menu Handle.
6.33 + * @param flags A new bitstring of MENUFLAG bits.
6.34 + * @noreturn
6.35 + * @error Invalid Handle.
6.36 + */
6.37 +native SetMenuOptionFlags(Handle:menu, flags);
6.38 +
6.39 +/**
6.40 * Returns whether a vote is in progress on the given menu.
6.41 *
6.42 * @param menu Menu Handle.
7.1 --- a/public/IMenuManager.h Fri Aug 03 11:14:56 2007 +0000
7.2 +++ b/public/IMenuManager.h Fri Aug 03 11:40:21 2007 +0000
7.3 @@ -37,7 +37,7 @@
7.4 #include <IHandleSys.h>
7.5
7.6 #define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
7.7 -#define SMINTERFACE_MENUMANAGER_VERSION 7
7.8 +#define SMINTERFACE_MENUMANAGER_VERSION 8
7.9
7.10 /**
7.11 * @file IMenuManager.h
7.12 @@ -147,6 +147,10 @@
7.13 #define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
7.14 #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
7.15
7.16 + #define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button */
7.17 + #define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
7.18 + #define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
7.19 +
7.20 /**
7.21 * @brief Extended menu options.
7.22 */
7.23 @@ -567,6 +571,20 @@
7.24 * @param set True to enable, false to disable.
7.25 */
7.26 virtual void SetExitBackButton(bool set) =0;
7.27 +
7.28 + /**
7.29 + * @brief Returns menu option flags.
7.30 + *
7.31 + * @return Menu option flags.
7.32 + */
7.33 + virtual unsigned int GetMenuOptionFlags() =0;
7.34 +
7.35 + /**
7.36 + * @brief Sets menu option flags.
7.37 + *
7.38 + * @param flags Menu option flags.
7.39 + */
7.40 + virtual void SetMenuOptionFlags(unsigned int flags) =0;
7.41 };
7.42
7.43 /**