diff -r 6f440a361fa7 -r 4f111b467bfa core/MenuManager.cpp --- a/core/MenuManager.cpp Tue Jul 31 02:08:25 2007 +0000 +++ b/core/MenuManager.cpp Tue Jul 31 18:56:55 2007 +0000 @@ -22,9 +22,12 @@ #include "MenuStyle_Valve.h" #include "ShareSys.h" #include "HandleSys.h" +#include "sourcemm_api.h" MenuManager g_Menus; +ConVar sm_menu_sounds("sm_menu_sounds", "1", 0, "Sets whether SourceMod menus play trigger sounds"); + /******************************* ******************************* ******** VOTE HANDLER ********* @@ -803,3 +806,60 @@ 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; +}