def __loadConfig(self): eventNames = {} xmlPath = 'gui/music_events.xml' section = ResMgr.openSection(xmlPath) if section is None: _xml.raiseWrongXml(None, xmlPath, 'can not open or read') for i in section.items(): s = i[1] if i[0] == 'music': eventNames[MUSIC_EVENT_LOGIN] = s.readString('login') eventNames[MUSIC_EVENT_LOBBY] = (s.readString('lobby'), s.readString('lobby_premium')) eventNames[MUSIC_EVENT_COMBAT_VICTORY] = s.readString('combat_victory') eventNames[MUSIC_EVENT_COMBAT_LOSE] = s.readString('combat_lose') eventNames[MUSIC_EVENT_COMBAT_DRAW] = s.readString('combat_draw') elif i[0] == 'ambient': eventNames[AMBIENT_EVENT_LOBBY] = (s.readString('lobby'), s.readString('lobby_premium')) eventNames[AMBIENT_EVENT_SHOP] = (s.readString('shop'), s.readString('shop_premium')) eventNames[AMBIENT_EVENT_STATISTICS] = (s.readString('rating'), s.readString('rating_premium')) fallbackEventNames = eventNames.copy() for eventId, overriddenNames in self.__overriddenEvents.iteritems(): eventNames[eventId] = overriddenNames soundsByName = {} for eventId, names in eventNames.items(): lstEvents = [] if not isinstance(names, tuple): names = (names,) fallbackNames = fallbackEventNames[eventId] if not isinstance(fallbackNames, tuple): fallbackNames = (fallbackNames,) for i in xrange(len(names)): eventName = names[i] fallbackEventName = fallbackNames[i] sound = soundsByName.get(eventName) if sound is None: sound = FMOD.getSound(eventName) if eventName != '' else None if sound is None: sound = FMOD.getSound(fallbackEventName) if fallbackEventName != '' else None soundsByName[eventName] = sound lstEvents.append(sound) if sound is not None: sound.stop() self.__soundEvents[eventId] = lstEvents return
def _playGUI(self, event): if self.__ignoreNext: self.__ignoreNext = False return if event is context.SOUND_EVENT.NEXT_CHAPTER: self.__ignoreNext = True sndID = self.__guiSounds[event] sound = FMOD.getSound(sndID) if sound: sound.play() else: LOG_ERROR('Sound not found', sndID)
def _playGUI(self, event): if self.__ignoreNext: self.__ignoreNext = False return if event is context.SOUND_EVENT.NEXT_CHAPTER: self.__ignoreNext = True sndID = self.__guiSounds[event] sound = FMOD.getSound(sndID) if sound: sound.play() else: LOG_ERROR("Sound not found", sndID)
def __getArenaSoundEvent(self, eventId): player = BigWorld.player() soundEvent = None soundEventName = None if not isPlayerAvatar(): return elif player.arena is None: return else: arenaType = player.arena.arenaType if eventId == MUSIC_EVENT_COMBAT: soundEventName = arenaType.music elif eventId == MUSIC_EVENT_COMBAT_LOADING: soundEventName = arenaType.loadingMusic elif eventId == AMBIENT_EVENT_COMBAT: soundEventName = arenaType.ambientSound if soundEventName is not None: soundEvent = FMOD.getSound(soundEventName) if soundEvent is not None: soundEvent.stop() return soundEvent
def _speak(self, sndID): if sndID in self.__prevSpeaks: LOG_DEBUG('Speaking played, ignore', sndID) return elif sndID is None: LOG_WARNING('Sound ID for speaking is not defined') return elif self.__speakSnd is not None: self.__nextSndID = sndID return else: sound = FMOD.getSound(sndID) if not sound: LOG_ERROR('Sound not found', sndID) return self.__nextSndID = None self.__speakSnd = sound self.__prevSpeaks.add(sndID) sound.setCallback('EVENTFINISHED', self.__onSpeakingStop) sound.play() return
def _speak(self, sndID): if sndID in self.__prevSpeaks: LOG_DEBUG("Speaking played, ignore", sndID) return elif sndID is None: LOG_WARNING("Sound ID for speaking is not defined") return elif self.__speakSnd is not None: self.__nextSndID = sndID return else: sound = FMOD.getSound(sndID) if not sound: LOG_ERROR("Sound not found", sndID) return self.__nextSndID = None self.__speakSnd = sound self.__prevSpeaks.add(sndID) sound.setCallback("EVENTFINISHED", self.__onSpeakingStop) sound.play() return
def getSound2D(self, event): if FMOD.enabled: return FMOD.getSound(self.checkAndReplace(event))
def FMODgetSound(self, event): return FMOD.getSound(self.checkAndReplace(event))
def __init__(self, soundPath): self.__sndTick = FMOD.getSound(soundPath) self.__isPlaying = True self.stop()