def loadSyncsounds(self): """ Load sync sounds ..deprecated:: 4.0.0 """ return [Sound(self.resource.fileName("sync%d.ogg" % i)) for i in range(1, 2)]
def loadAcceptSounds(self): """ Load accept sounds (prefix: accept). :return: list of ``Sound`` objects """ soundPathTheme = os.path.join("themes", self.themeLabel, "sounds") soundPath = soundPathTheme soundPrefix = "accept" numSounds = self.determineNumSounds(soundPath, soundPrefix) if numSounds > 0: return self.getSoundObjectList(soundPath, soundPrefix, numSounds) else: if self.theme == 0 or self.theme == 1: # GH2 or GH3 return [Sound(self.resource.fileName(os.path.join("themes", self.themeLabel, "sounds", "in.ogg")))] elif self.theme == 2: return [Sound(self.resource.fileName(os.path.join("themes", self.themeLabel, "sounds", "action.ogg")))]
def loadSoundEffect(self, target, name, fileName, crowd=False): volume = self.sfxVolume if crowd: volume = self.crowdVolume fileName = self.resource.fileName(fileName) self.resource.load(target, name, lambda: Sound(fileName), onLoad=lambda s: s.setVolume(volume))
def loadBackSounds(self): soundPathTheme = os.path.join("themes", self.themeLabel, "sounds") soundPath = soundPathTheme soundPrefix = "back" numSounds = self.determineNumSounds(soundPath, soundPrefix) if numSounds > 0: return self.getSoundObjectList(soundPath, soundPrefix, numSounds) else: return [ Sound( self.resource.fileName( os.path.join("themes", self.themeLabel, "sounds", "out.ogg"))) ]
def getSoundObjectList(self, soundPath, soundPrefix, numSounds, soundExtension=".ogg"): # MFH log.debug("{0}1{2} - {0}{1}{2} found in {3}".format( soundPrefix, numSounds, soundExtension, soundPath)) sounds = [] for i in xrange(1, numSounds + 1): filePath = os.path.join( soundPath, "%s%d%s" % (soundPrefix, i, soundExtension)) soundObject = Sound(self.resource.fileName(filePath)) sounds.append(soundObject) return sounds
def loadBackSounds( self ): #MFH - adding optional support for random choice between two back sounds soundPathTheme = os.path.join("themes", self.themeLabel, "sounds") soundPath = soundPathTheme soundPrefix = "back" numSounds = self.determineNumSounds(soundPath, soundPrefix) if numSounds > 0: return self.getSoundObjectList(soundPath, soundPrefix, numSounds) else: return [ Sound( self.resource.fileName( os.path.join("themes", self.themeLabel, "sounds", "out.ogg"))) ]
def getSoundObjectList(self, soundPath, soundPrefix, numSounds, soundExtension=".ogg"): """ Get ``Sound`` objects for sounds with the following pattern: <prefix><int><extension>. :param soundPath: path of sounds :param soundPrefix: prefix of sounds :param numSounds: number of sounds :param soundExtension: extension of sounds (default: ogg) :return: the list of ``Sound`` objets found """ log.debug("{0}1{2} - {0}{1}{2} found in {3}".format(soundPrefix, numSounds, soundExtension, soundPath)) sounds = [] for i in xrange(1, numSounds + 1): filePath = os.path.join(soundPath, "%s%d%s" % (soundPrefix, i, soundExtension)) soundObject = Sound(self.resource.fileName(filePath)) sounds.append(soundObject) return sounds
def loadSyncsounds(self): return [ Sound(self.resource.fileName("sync%d.ogg" % i)) for i in range(1, 2) ]