def __init__(self, *args, **kwargs): super(MenuBar, self).__init__(*args, **kwargs) self.menulist = [] self._buttonlist = [] self.gui = None self._buildGui() self._timer = fife_timer.Timer(500, self._autoHideMenu) self._timer.start()
def playClip(self, clip): """ Plays a sound clip. This function does not use the L{fife.SoundEmitter} "looping" property to loop a sound. Instead it registers a new timer and uses the duration of the clip as the timer length. If the SoundEmitter is invalid (no fifeemitter) then it attempts to load it before playing it. @note: This will stop any clips that use the same L{fife.SoundEmitter}. You cannot play the same sound more than once at a time unless you create the SoundEmitter with the forceUnique paramater set to True. @param clip: The L{SoundEmitter} to be played @type clip: L{SoundEmitter} """ if clip.fifeemitter: if clip.callback: if clip.timer: clip.timer.stop() timer = None if clip.looping: repeat = 0 def real_callback(clip): clip.fifeemitter.stop() clip.fifeemitter.setGain(float(clip.gain) / 255.0) if self.listenerposition and clip.position: # Use 1 as z coordinate, no need to specify it clip.fifeemitter.setPosition( clip.position[0], clip.position[1], 1) clip.fifeemitter.setRolloff(clip.rolloff) elif self.listenerposition and not clip.position: clip.fifeemitter.setPosition( self._listenerposition[0], self._listenerposition[1], 1) clip.fifeemitter.setRolloff(self.rolloff) clip.fifeemitter.play() clip.callback = cbwa(real_callback, clip) else: repeat = 1 clip.timer = fife_timer.Timer(clip.duration, clip.callback, repeat) else: if clip.looping: def real_callback(clip): clip.fifeemitter.stop() clip.fifeemitter.setGain(float(clip.gain) / 255.0) if self.listenerposition and clip.position: # Use 1 as z coordinate, no need to specify it clip.fifeemitter.setPosition( clip.position[0], clip.position[1], 1) clip.fifeemitter.setRolloff(clip.rolloff) elif self.listenerposition and not clip.position: clip.fifeemitter.setPosition( self._listenerposition[0], self._listenerposition[1], 1) clip.fifeemitter.setRolloff(self.rolloff) clip.fifeemitter.play() clip.callback = cbwa(real_callback, clip) clip.timer = fife_timer.Timer(clip.duration, clip.callback, 0) clip.fifeemitter.setGain(float(clip.gain) / 255.0) if self.listenerposition and clip.position: # Use 1 as z coordinate, no need to specify it clip.fifeemitter.setPosition(clip.position[0], clip.position[1], 1) clip.fifeemitter.setRolloff(clip.rolloff) elif self.listenerposition and not clip.position: clip.fifeemitter.setPosition(self._listenerposition[0], self._listenerposition[1], 1) clip.fifeemitter.setRolloff(self.rolloff) clip.fifeemitter.play() if clip.timer: clip.timer.start() else: clip = self.createSoundEmitter(clip.name) self.playClip(clip)