def preloadSoundGroups(self, arenaName): if not FMOD.enabled: return self.groupList = [] settings = ResMgr.openSection('scripts/arena_defs/' + arenaName + '.xml/preloadSoundGroups') if settings is not None: self.groupList = settings.readStrings('groupName') for sg in self.groupList: result = FMOD.WG_loadSoundGroup(sg) if not result: LOG_NOTE('Loading failed for arena sound group ', sg)
def __init__(self): self.__volumeByCategory = {} self.__masterVolume = 1.0 self.__replace = {} self.__isWindowVisible = BigWorld.isWindowVisible() self.__handleInside = None self.__handleOutside = None self.__ceilLess = None self.__activeStinger = None self.__activeTrack = None self.__activeStingerPriority = None self.__muffled = False self.__muffledByReplay = False PlayerEvents.g_playerEvents.onAvatarReady += self.onAvatarReady self.__categories = {'voice': ('ingame_voice',), 'vehicles': ('outside/vehicles', 'vehicles', 'inside/vehicles'), 'effects': ('hits', 'outside/hits', 'inside/hits', 'weapons', 'inside/weapons', 'outside/weapons', 'environment', 'inside/environment', 'outside/environment', 'battle_gui'), 'gui': ('gui',), 'music': ('music',), 'ambient': ('outside/ambient', 'hangar_v2', 'ambientUR'), 'masterVivox': (), 'micVivox': (), 'masterFadeVivox': ()} defMasterVolume = 0.5 defCategoryVolumes = {'music': 0.5, 'masterVivox': 0.7, 'micVivox': 0.4} userPrefs = Settings.g_instance.userPrefs soundModeName = SoundModes.DEFAULT_MODE_NAME nationalMapping = None self.__soundModes = None if not userPrefs.has_key(Settings.KEY_SOUND_PREFERENCES): userPrefs.write(Settings.KEY_SOUND_PREFERENCES, '') self.__masterVolume = defMasterVolume for categoryName in self.__categories.keys(): self.__volumeByCategory[categoryName] = defCategoryVolumes.get(categoryName, 1.0) self.savePreferences() else: ds = userPrefs[Settings.KEY_SOUND_PREFERENCES] self.__masterVolume = ds.readFloat('masterVolume', defMasterVolume) for categoryName in self.__categories.keys(): volume = ds.readFloat('volume_' + categoryName, defCategoryVolumes.get(categoryName, 1.0)) self.__volumeByCategory[categoryName] = volume soundModeSec = ds['soundMode'] if soundModeSec is not None: soundModeName = soundModeSec.asString if soundModeName == '': soundModeName = SoundModes.DEFAULT_MODE_NAME if ds['soundMode'].has_key('nationalPreset'): nationalMapping = ds.readString('soundMode/nationalPreset', '') else: nationsSec = soundModeSec['nations'] if nationsSec is not None: nationalMapping = {} for nation, sec in nationsSec.items(): nationalMapping[nation] = sec.asString self.__soundModes = SoundModes(SoundModes.DEFAULT_MODE_NAME) if isinstance(nationalMapping, str): self.__soundModes.setNationalMappingByPreset(nationalMapping) elif isinstance(nationalMapping, dict): self.__soundModes.setNationalMapping(nationalMapping) else: self.__soundModes.setNationalMappingByMode(soundModeName) self.applyPreferences() self.__muteCallbackID = BigWorld.callback(0.25, self.__muteByWindowVisibility) self.defaultGroupList = [] settings = ResMgr.openSection('scripts/arena_defs/_default_.xml/preloadSoundGroups') if settings is not None: self.defaultGroupList = settings.readStrings('groupName') if FMOD.enabled: for sg in self.defaultGroupList: result = FMOD.WG_loadSoundGroup(sg) if not result: LOG_NOTE('Loading failed for default sound group ', sg) FMOD.WG_unloadAll() g_replayEvents.onMuteSound += self.__onReplayMute