class SoundManager(SoundManagerMeta):
    def __init__(self):
        super(SoundManager, self).__init__()
        self.sounds = GuiSoundsLoader()

    def _populate(self):
        super(SoundManager, self)._populate()
        try:
            self.sounds.load()
        except Exception:
            LOG_ERROR('There is error while loading sounds xml data')
            LOG_CURRENT_EXCEPTION()

    def soundEventHandler(self, soundsTypeSection, state, eventType, eventID):
        self.playControlSound(state, eventType, eventID)

    def playControlSound(self, state, eventType, eventID):
        sound = self.sounds.getControlSound(eventType, state, eventID)
        if sound is not None:
            SoundGroups.g_instance.playSound2D(sound)
            if state == 'press':
                VibroManager.g_instance.playButtonClickEffect(eventType)
        return

    def playEffectSound(self, effectName):
        sound = self.sounds.getEffectSound(effectName)
        if sound is not None:
            SoundGroups.g_instance.playSound2D(sound)
        else:
            _logger.warning('Sound effect "%s" not found', effectName)
        return
Пример #2
0
class SoundManager(SoundManagerMeta):
    def __init__(self):
        DAAPIModule.__init__(self)
        self.sounds = GuiSoundsLoader()

    def _populate(self):
        super(SoundManager, self)._populate()
        try:
            self.sounds.load()
        except Exception:
            LOG_ERROR('There is error while loading sounds xml data')
            LOG_CURRENT_EXCEPTION()

    def soundEventHandler(self, soundsTypeSection, state, type, id):
        self.playControlSound(state, type, id)

    def playControlSound(self, state, type, id):
        sound = self.sounds.getControlSound(type, state, id)
        if sound is not None:
            Sound(sound).play()
            if state == 'press':
                VibroManager.g_instance.playButtonClickEffect(type)
        return

    def playEffectSound(self, effectName):
        sound = self.sounds.getEffectSound(effectName)
        if sound is not None:
            Sound(sound).play()
        return
Пример #3
0
class SoundManager(SoundManagerMeta):

    def __init__(self):
        DAAPIModule.__init__(self)
        self.sounds = GuiSoundsLoader()

    def _populate(self):
        super(SoundManager, self)._populate()
        try:
            self.sounds.load()
        except Exception:
            LOG_ERROR('There is error while loading sounds xml data')
            LOG_CURRENT_EXCEPTION()

    def soundEventHandler(self, soundsTypeSection, state, type, id):
        self.playControlSound(state, type, id)

    def playControlSound(self, state, type, id):
        sound = self.sounds.getControlSound(type, state, id)
        if sound is not None:
            Sound(sound).play()
            if state == 'press':
                VibroManager.g_instance.playButtonClickEffect(type)
        return

    def playEffectSound(self, effectName):
        sound = self.sounds.getEffectSound(effectName)
        if sound is not None:
            Sound(sound).play()
        return
 def __init__(self):
     super(SoundManager, self).__init__()
     self.sounds = GuiSoundsLoader()
Пример #5
0
 def __init__(self):
     DAAPIModule.__init__(self)
     self.sounds = GuiSoundsLoader()
Пример #6
0
 def __init__(self):
     super(SoundManager, self).__init__()
     self.sounds = GuiSoundsLoader()
Пример #7
0
 def __init__(self):
     self.__soundEvents = {}
     self.__loadConfig()
     self.sounds = GuiSoundsLoader()
Пример #8
0
class SoundManager(UIInterface):
    def __init__(self):
        self.__soundEvents = {}
        self.__loadConfig()
        self.sounds = GuiSoundsLoader()

    def __loadConfig(self):
        xmlPath = 'gui/gui_sounds.xml'
        section = ResMgr.openSection(xmlPath)
        if section is None:
            _xml.raiseWrongXml(None, xmlPath, 'can not open or read')
        for groupName, types in section.items():
            self.__soundEvents[groupName] = SoundSettings.populateSettings(
                types)

    def populateUI(self, proxy):
        UIInterface.populateUI(self, proxy)
        sm = self.uiHolder.movie.soundManager
        sm.script = self
        try:
            self.sounds.load()
        except Exception:
            LOG_ERROR('There is error while loading sounds xml data')
            LOG_CURRENT_EXCEPTION()

    def soundEventHandler(self, control, state, type, id):
        self.tryPlaySnd(control, state, type, id)

    def dispossessUI(self):
        self.uiHolder.movie.soundManager.script = None
        UIInterface.dispossessUI(self)

    def playSound(self, dictPath):
        if dictPath is None:
            return
        scope = self.__soundEvents
        for key in str(dictPath).split('.'):
            if key not in scope:
                return
            scope = scope[key]

        if type(scope) != str:
            LOG_ERROR('Invalid soundpath under key: %s', dictPath)
            return
        Sound(scope).play()

    def playEffectSound(self, effectName):
        sound = self.sounds.getEffectSound(effectName)
        if sound is not None:
            Sound(sound).play()

    def onButtonEvent(self, callbackID, state, type, id):
        self.tryPlaySnd('buttons', state, type, id)

    def onItemRendererEvent(self, callbackID, state, type):
        self.tryPlaySnd('itemRenderer', state, type, 'fakeId')

    def tryPlaySnd(self, sndType, state, type, id):
        sound = self.__soundEvents.get(sndType, SoundSettings()).getSoundName(
            type, id, state)
        if sound:
            Sound(sound).play()
            if state == 'press':
                Vibroeffects.VibroManager.g_instance.playButtonClickEffect(
                    type)
Пример #9
0
 def __init__(self):
     self.__soundEvents = {}
     self.__loadConfig()
     self.sounds = GuiSoundsLoader()
Пример #10
0
class SoundManager(UIInterface):

    def __init__(self):
        self.__soundEvents = {}
        self.__loadConfig()
        self.sounds = GuiSoundsLoader()



    def __loadConfig(self):
        xmlPath = 'gui/gui_sounds.xml'
        section = ResMgr.openSection(xmlPath)
        if section is None:
            _xml.raiseWrongXml(None, xmlPath, 'can not open or read')
        for (groupName, types,) in section.items():
            self.__soundEvents[groupName] = SoundSettings.populateSettings(types)




    def populateUI(self, proxy):
        UIInterface.populateUI(self, proxy)
        sm = self.uiHolder.movie.soundManager
        sm.script = self
        try:
            self.sounds.load()
        except Exception:
            LOG_ERROR('There is error while loading sounds xml data')
            LOG_CURRENT_EXCEPTION()



    def soundEventHandler(self, control, state, type, id):
        self.tryPlaySnd(control, state, type, id)



    def dispossessUI(self):
        self.uiHolder.movie.soundManager.script = None
        UIInterface.dispossessUI(self)



    def playSound(self, dictPath):
        if dictPath is None:
            return 
        scope = self.__soundEvents
        for key in str(dictPath).split('.'):
            if key not in scope:
                return 
            scope = scope[key]

        if type(scope) != str:
            LOG_ERROR('Invalid soundpath under key: %s', dictPath)
            return 
        Sound(scope).play()



    def playEffectSound(self, effectName):
        sound = self.sounds.getEffectSound(effectName)
        if sound is not None:
            Sound(sound).play()



    def onButtonEvent(self, callbackID, state, type, id):
        self.tryPlaySnd('buttons', state, type, id)



    def onItemRendererEvent(self, callbackID, state, type):
        self.tryPlaySnd('itemRenderer', state, type, 'fakeId')



    def tryPlaySnd(self, sndType, state, type, id):
        sound = self.__soundEvents.get(sndType, SoundSettings()).getSoundName(type, id, state)
        if sound:
            Sound(sound).play()
            if state == 'press':
                Vibroeffects.VibroManager.g_instance.playButtonClickEffect(type)
Пример #11
0
 def __init__(self):
     DAAPIModule.__init__(self)
     self.sounds = GuiSoundsLoader()