added amb704 (menu sound support)
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401226
This commit is contained in:
parent
d05a57fcba
commit
b0e107bdfb
@ -13,6 +13,12 @@
|
|||||||
// Default: 13 (1+4+8)
|
// Default: 13 (1+4+8)
|
||||||
sm_show_activity 13
|
sm_show_activity 13
|
||||||
|
|
||||||
|
// Specifies whether menu sounds are enabled for menus created by SourceMod.
|
||||||
|
// Menu sounds can be further configured in addons/sourcemod/configs/core.cfg.
|
||||||
|
// --
|
||||||
|
// Default: 1
|
||||||
|
sm_menu_sounds 1
|
||||||
|
|
||||||
// Specifies the amount of time that is allowed between chat messages. This
|
// Specifies the amount of time that is allowed between chat messages. This
|
||||||
// includes the say and say_team commands. If a client sends a message faster
|
// includes the say and say_team commands. If a client sends a message faster
|
||||||
// than this time, they receive a flood token. When the client has accumulated
|
// than this time, they receive a flood token. When the client has accumulated
|
||||||
|
@ -52,4 +52,16 @@
|
|||||||
* passwords to work, for security reasons.
|
* passwords to work, for security reasons.
|
||||||
*/
|
*/
|
||||||
"PassInfoVar" "_password"
|
"PassInfoVar" "_password"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the sound that gets played when an item is selected from a menu.
|
||||||
|
*/
|
||||||
|
"MenuItemSound" "buttons/button14.wav"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the sound that gets played when an "Exit Back" button is selected
|
||||||
|
* from a menu. This is the special "Back" button that is intended to roll back
|
||||||
|
* to a previous menu.
|
||||||
|
*/
|
||||||
|
"MenuExitBackSound" "buttons/combine_button7.wav"
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,12 @@
|
|||||||
#include "MenuStyle_Valve.h"
|
#include "MenuStyle_Valve.h"
|
||||||
#include "ShareSys.h"
|
#include "ShareSys.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
|
#include "sourcemm_api.h"
|
||||||
|
|
||||||
MenuManager g_Menus;
|
MenuManager g_Menus;
|
||||||
|
|
||||||
|
ConVar sm_menu_sounds("sm_menu_sounds", "1", 0, "Sets whether SourceMod menus play trigger sounds");
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
*******************************
|
*******************************
|
||||||
******** VOTE HANDLER *********
|
******** VOTE HANDLER *********
|
||||||
@ -803,3 +806,60 @@ void MenuManager::ReleaseVoteWrapper(IVoteMenuHandler *mh)
|
|||||||
|
|
||||||
m_VoteHandlers.push((VoteMenuHandler *)mh);
|
m_VoteHandlers.push((VoteMenuHandler *)mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MenuManager::MenuSoundsEnabled()
|
||||||
|
{
|
||||||
|
return (sm_menu_sounds.GetInt() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigResult MenuManager::OnSourceModConfigChanged(const char *key,
|
||||||
|
const char *value,
|
||||||
|
ConfigSource source,
|
||||||
|
char *error,
|
||||||
|
size_t maxlength)
|
||||||
|
{
|
||||||
|
if (strcmp(key, "MenuItemSound") == 0)
|
||||||
|
{
|
||||||
|
m_SelectSound.assign(value);
|
||||||
|
return ConfigResult_Accept;
|
||||||
|
} else if (strcmp(key, "MenuExitBackSound") == 0) {
|
||||||
|
m_ExitBackSound.assign(value);
|
||||||
|
return ConfigResult_Accept;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConfigResult_Ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *MenuManager::GetMenuSound(ItemSelection sel)
|
||||||
|
{
|
||||||
|
const char *sound = NULL;
|
||||||
|
|
||||||
|
switch (sel)
|
||||||
|
{
|
||||||
|
case ItemSel_Back:
|
||||||
|
case ItemSel_Next:
|
||||||
|
case ItemSel_Exit:
|
||||||
|
case ItemSel_Item:
|
||||||
|
{
|
||||||
|
if (m_SelectSound.size() > 0)
|
||||||
|
{
|
||||||
|
sound = m_SelectSound.c_str();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemSel_ExitBack:
|
||||||
|
{
|
||||||
|
if (m_ExitBackSound.size() > 0)
|
||||||
|
{
|
||||||
|
sound = m_ExitBackSound.c_str();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sound;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <sh_vector.h>
|
#include <sh_vector.h>
|
||||||
#include <sh_stack.h>
|
#include <sh_stack.h>
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
|
#include <sh_string.h>
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
|
|
||||||
@ -72,6 +73,11 @@ public:
|
|||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModAllShutdown();
|
void OnSourceModAllShutdown();
|
||||||
|
ConfigResult OnSourceModConfigChanged(const char *key,
|
||||||
|
const char *value,
|
||||||
|
ConfigSource source,
|
||||||
|
char *error,
|
||||||
|
size_t maxlength);
|
||||||
public: //IMenuManager
|
public: //IMenuManager
|
||||||
virtual const char *GetInterfaceName()
|
virtual const char *GetInterfaceName()
|
||||||
{
|
{
|
||||||
@ -96,6 +102,9 @@ public: //IHandleTypeDispatch
|
|||||||
public:
|
public:
|
||||||
HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
|
HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
|
||||||
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
|
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
|
||||||
|
public:
|
||||||
|
bool MenuSoundsEnabled();
|
||||||
|
const char *GetMenuSound(ItemSelection sel);
|
||||||
protected:
|
protected:
|
||||||
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
|
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
|
||||||
Handle_t CreateStyleHandle(IMenuStyle *style);
|
Handle_t CreateStyleHandle(IMenuStyle *style);
|
||||||
@ -106,6 +115,8 @@ private:
|
|||||||
CVector<IMenuStyle *> m_Styles;
|
CVector<IMenuStyle *> m_Styles;
|
||||||
HandleType_t m_StyleType;
|
HandleType_t m_StyleType;
|
||||||
HandleType_t m_MenuType;
|
HandleType_t m_MenuType;
|
||||||
|
String m_SelectSound;
|
||||||
|
String m_ExitBackSound;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MenuManager g_Menus;
|
extern MenuManager g_Menus;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "MenuManager.h"
|
#include "MenuManager.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
|
#include "CellRecipientFilter.h"
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#endif
|
#endif
|
||||||
@ -276,6 +277,42 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
} else {
|
} else {
|
||||||
ItemSelection type = states.slots[key_press].type;
|
ItemSelection type = states.slots[key_press].type;
|
||||||
|
|
||||||
|
/* Check if we should play a sound about the type */
|
||||||
|
if (g_Menus.MenuSoundsEnabled())
|
||||||
|
{
|
||||||
|
CellRecipientFilter filter;
|
||||||
|
cell_t clients[1];
|
||||||
|
|
||||||
|
clients[0] = client;
|
||||||
|
filter.Initialize(clients, 1);
|
||||||
|
|
||||||
|
const char *sound = g_Menus.GetMenuSound(type);
|
||||||
|
|
||||||
|
if (sound != NULL)
|
||||||
|
{
|
||||||
|
edict_t *pEdict = engine->PEntityOfEntIndex(client);
|
||||||
|
if (pEdict)
|
||||||
|
{
|
||||||
|
ICollideable *pCollideable = pEdict->GetCollideable();
|
||||||
|
|
||||||
|
if (pCollideable)
|
||||||
|
{
|
||||||
|
const Vector & pos = pCollideable->GetCollisionOrigin();
|
||||||
|
|
||||||
|
enginesound->EmitSound(filter,
|
||||||
|
client,
|
||||||
|
CHAN_AUTO,
|
||||||
|
sound,
|
||||||
|
VOL_NORM,
|
||||||
|
ATTN_NORM,
|
||||||
|
0,
|
||||||
|
PITCH_NORM,
|
||||||
|
&pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* For navigational items, we're going to redisplay */
|
/* For navigational items, we're going to redisplay */
|
||||||
if (type == ItemSel_Back)
|
if (type == ItemSel_Back)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user