Beispiel #1
0
    def _restartSounds(self):
        result = []
        for layer in (WindowLayer.TOP_WINDOW, WindowLayer.WINDOW,
                      WindowLayer.SUB_VIEW, WindowLayer.TOP_SUB_VIEW):
            result.extend(self._customEnvs[layer].values())

        result.append(self._spaceEnv)
        music, ambient = EmptySound(), EmptySound()
        while result and (music.isEmpty() or ambient.isEmpty()):
            env = result.pop(0)
            m, a = env.getMusicEvent(), env.getAmbientEvent()
            if music.isEmpty() and not m.isEmpty():
                music = m
            if ambient.isEmpty() and not a.isEmpty():
                ambient = a

        SOUND_DEBUG('Starting sound events', music, ambient)
        for event in (music, ambient):
            event.start()
Beispiel #2
0
    def _restartSounds(self):
        result = []
        for vt in (ViewTypes.TOP_WINDOW, ViewTypes.WINDOW,
                   ViewTypes.LOBBY_TOP_SUB, ViewTypes.LOBBY_SUB):
            result.extend(self._customEnvs[vt].values())

        result.append(self._spaceEnv)
        music, ambient = EmptySound(), EmptySound()
        while result and (music.isEmpty() or ambient.isEmpty()):
            env = result.pop(0)
            m, a = env.getMusicEvent(), env.getAmbientEvent()
            if music.isEmpty() and not m.isEmpty():
                music = m
            if ambient.isEmpty() and not a.isEmpty():
                ambient = a

        SOUND_DEBUG('Starting sound events', music, ambient)
        for event in (music, ambient):
            event.start()
Beispiel #3
0
    def __onGUISpaceLeft(self, spaceID):
        """ Explicitly clear custom sound environments when leaving space.
        
        We don't have to wait for an actual view disposal since it might be
        delayed for a significant amount of time.
        """
        SOUND_DEBUG('Leaving GUI space', spaceID, spaceID in self._spaces)
        if self.app is not None and self.app.containerManager is not None and spaceID in self._spaces:
            customViews = []
            for vt in (ViewTypes.TOP_WINDOW, ViewTypes.WINDOW,
                       ViewTypes.LOBBY_SUB):
                container = self.app.containerManager.getContainer(vt)
                for viewAlias in self._customEnvs[vt].iterkeys():
                    view = container.getView(
                        criteria={POP_UP_CRITERIA.VIEW_ALIAS: viewAlias})
                    if view is not None:
                        customViews.append(view)

            for view in customViews:
                self.__onViewDisposed(view)

        return
Beispiel #4
0
 def __init__(self):
     super(SoundsController, self).__init__()
     self.__soundSystem = getCurrentSoundSystem()
     self.__guiAmbients = GuiAmbientsCtrl(weakref.proxy(self))
     SOUND_DEBUG('Sound system has been created', self.__soundSystem)
Beispiel #5
0
 def __onAmbientChanged(self, ambient):
     SOUND_DEBUG('Ambient has been changed', ambient)
     self._restartSounds()
Beispiel #6
0
 def __removeSoundEnv(self, view, uniqueName):
     env = self._clearSoundEnv(self._customEnvs[view.viewType][uniqueName],
                               view)
     SOUND_DEBUG('Custom sound environ has been stopped', view.alias, env)
     del self._customEnvs[view.viewType][uniqueName]
Beispiel #7
0
 def __onGUISpaceEntered(self, spaceID):
     SOUND_DEBUG('Entering GUI space', spaceID, spaceID in self._spaces)
     if spaceID in self._spaces:
         self._clearSoundEnv(self._spaceEnv)
         self._spaceEnv = self._buildSoundEnv(self._spaces[spaceID])
         self._restartSounds()
Beispiel #8
0
 def _setAfterBattleAmbient(self):
     SOUND_DEBUG('Stop battle ambient sounds in the afterbattle period')
     self._music = NoMusic()
     self._onChanged()
Beispiel #9
0
 def _onCheckAmbientNotification(self):
     SOUND_DEBUG('Current ambient playing check: is playing now', self,
                 self.isPlaying())
     if not self.isPlaying():
         self.onFinished(self.isCompleted())
Beispiel #10
0
 def _setMusicParam(self, paramName, value):
     SOUND_DEBUG('Change music parameter', paramName, value)
     self._music.setParam(paramName, value)
Beispiel #11
0
 def _setAmbientParam(self, paramName, value):
     SOUND_DEBUG('Change ambient parameter', paramName, value)
     self._ambient.setParam(paramName, value)
Beispiel #12
0
 def stop(self):
     SOUND_DEBUG('Stopping ambient sound event')
     _MC.g_musicController.stopAmbient()
Beispiel #13
0
 def stop(self):
     SOUND_DEBUG('Stopping music sound event')
     _MC.g_musicController.stopMusic()
Beispiel #14
0
 def __setAccountAttrs(self, restartSounds=False):
     SOUND_DEBUG('Set current account premium state', self.itemsCache.items.stats.isPremium, restartSounds)
     _MC.g_musicController.setAccountPremiumState(self.itemsCache.items.stats.isPremium, restart=restartSounds)
Beispiel #15
0
 def __onPremiumChanged(self, isPremium, attrs, premiumExpiryTime):
     SOUND_DEBUG('Premium account status changed', isPremium, attrs,
                 premiumExpiryTime)
     self.__setAccountAttrs(restartSounds=True)
Beispiel #16
0
 def __setAccountAttrs(self, restartSounds=False):
     SOUND_DEBUG('Set current account attributes',
                 self.itemsCache.items.stats.attributes, restartSounds)
     _MC.g_musicController.setAccountAttrs(
         self.itemsCache.items.stats.attributes, restart=restartSounds)
Beispiel #17
0
 def _setBattleAmbient(self):
     SOUND_DEBUG('Change battle music event in the battle period')
     self._music = SoundEvent(_MC.MUSIC_EVENT_COMBAT)
     self._onChanged()