mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
removed want-sound, use 'audio-library-name null' instead
This commit is contained in:
parent
a885fa007a
commit
8ba7c32af2
@ -87,7 +87,6 @@ class DirectButton(DirectFrame):
|
||||
apply(self['command'], self['extraArgs'])
|
||||
|
||||
def setClickSound(self):
|
||||
if base.wantSfx:
|
||||
clickSound = self['clickSound']
|
||||
# Clear out sounds
|
||||
self.guiItem.clearSound(B1PRESS + self.guiId)
|
||||
@ -102,7 +101,6 @@ class DirectButton(DirectFrame):
|
||||
self.guiItem.setSound(B3PRESS + self.guiId, clickSound)
|
||||
|
||||
def setRolloverSound(self):
|
||||
if base.wantSfx:
|
||||
rolloverSound = self['rolloverSound']
|
||||
if rolloverSound:
|
||||
self.guiItem.setSound(ENTER + self.guiId, rolloverSound)
|
||||
|
@ -109,7 +109,6 @@ class DirectEntry(DirectFrame):
|
||||
PGEntry.setBackgroundFocus(self.guiItem, self['backgroundFocus'])
|
||||
|
||||
def setRolloverSound(self):
|
||||
if base.wantSfx:
|
||||
rolloverSound = self['rolloverSound']
|
||||
if rolloverSound:
|
||||
self.guiItem.setSound(ENTER + self.guiId, rolloverSound)
|
||||
@ -117,7 +116,6 @@ class DirectEntry(DirectFrame):
|
||||
self.guiItem.clearSound(ENTER + self.guiId)
|
||||
|
||||
def setClickSound(self):
|
||||
if base.wantSfx:
|
||||
clickSound = self['clickSound']
|
||||
if clickSound:
|
||||
self.guiItem.setSound(ACCEPT + self.guiId, clickSound)
|
||||
|
@ -76,8 +76,6 @@ panel = None
|
||||
|
||||
def getDefaultRolloverSound():
|
||||
global defaultRolloverSound
|
||||
if not base.wantSfx:
|
||||
return None
|
||||
if defaultRolloverSound == None:
|
||||
defaultRolloverSound = base.loadSfx(
|
||||
"phase_3/audio/sfx/GUI_rollover.mp3")
|
||||
@ -85,8 +83,6 @@ def getDefaultRolloverSound():
|
||||
|
||||
def getDefaultClickSound():
|
||||
global defaultClickSound
|
||||
if not base.wantSfx:
|
||||
return None
|
||||
if defaultClickSound == None:
|
||||
defaultClickSound = base.loadSfx(
|
||||
"phase_3/audio/sfx/GUI_create_toon_fwd.mp3")
|
||||
|
@ -28,10 +28,8 @@ class SoundInterval(Interval):
|
||||
self.sound = sound
|
||||
self.loop = loop
|
||||
self.volume = volume
|
||||
self.wantSound = base.wantSfx
|
||||
# If no duration given use sound's duration as interval's duration
|
||||
if duration == 0.0:
|
||||
if self.wantSound:
|
||||
if duration == 0.0 and self.sound != None:
|
||||
duration = self.sound.length()
|
||||
if (duration == 0):
|
||||
self.notify.warning('zero length duration!')
|
||||
@ -40,12 +38,6 @@ class SoundInterval(Interval):
|
||||
# DCR - hack for Miles bug - adding 1.5 seconds caused
|
||||
# problems for MG_neg_buzzer.wav
|
||||
duration += min(duration * 2.4, 1.5)
|
||||
else:
|
||||
# This will screw up any intervals that base their
|
||||
# time on the duration of this sound interval
|
||||
print ('SoundInterval: Warning, want-sound #f,'+
|
||||
' zero sound duration assumed')
|
||||
duration = 0.0
|
||||
# Generate unique name if necessary
|
||||
if (name == None):
|
||||
name = id
|
||||
@ -53,15 +45,12 @@ class SoundInterval(Interval):
|
||||
Interval.__init__(self, name, duration)
|
||||
# Update stopEvent
|
||||
self.stopEvent = id + '_stopEvent'
|
||||
if self.wantSound:
|
||||
self.stopEventList = [self.stopEvent]
|
||||
|
||||
def updateFunc(self, t, event = IVAL_NONE):
|
||||
""" updateFunc(t, event)
|
||||
Go to time t
|
||||
"""
|
||||
if not self.wantSound:
|
||||
return
|
||||
# Update sound based on current time
|
||||
if (t >= self.getDuration()):
|
||||
# If end of sound reached or stop event received, stop sound
|
||||
|
@ -39,18 +39,14 @@ class ShowBase:
|
||||
|
||||
# Store dconfig variables
|
||||
self.wantTk = self.config.GetBool('want-tk', 0)
|
||||
self.wantAnySound = self.config.GetBool('want-sound', 1)
|
||||
self.wantSfx = self.config.GetBool('audio-sfx-active', 1)
|
||||
self.wantMusic = self.config.GetBool('audio-music-active', 1)
|
||||
self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
|
||||
self.musicActive = self.config.GetBool('audio-music-active', 1)
|
||||
self.wantFog = self.config.GetBool('want-fog', 1)
|
||||
self.screenshotExtension = self.config.GetString('screenshot-extension', 'jpg')
|
||||
if not (self.wantSfx or self.wantMusic):
|
||||
self.wantAnySound = None
|
||||
if not self.wantAnySound:
|
||||
self.wantSfx = None
|
||||
self.wantMusic = None
|
||||
self.musicManager = None
|
||||
self.musicManagerIsValid = None
|
||||
self.sfxManager = None
|
||||
self.sfxManagerIsValid = None
|
||||
|
||||
self.wantDIRECT = self.config.GetBool('want-directtools', 0)
|
||||
self.wantStats = self.config.GetBool('want-stats', 0)
|
||||
@ -319,29 +315,28 @@ class ShowBase:
|
||||
PStatClient.connect()
|
||||
|
||||
def createAudioManager(self):
|
||||
if self.wantSfx:
|
||||
self.sfxManager = AudioManager.createAudioManager()
|
||||
if not self.sfxManager.isValid():
|
||||
self.wantSfx=None
|
||||
if self.wantMusic:
|
||||
self.sfxManagerIsValid=self.sfxManager!=None \
|
||||
and self.sfxManager.isValid()
|
||||
|
||||
self.musicManager = AudioManager.createAudioManager()
|
||||
self.musicManagerIsValid=self.musicManager!=None \
|
||||
and self.musicManager.isValid()
|
||||
|
||||
if self.musicManagerIsValid:
|
||||
# Turn down the music globally
|
||||
# Eventually we may want to control this in the options page
|
||||
self.musicManager.setVolume(0.7)
|
||||
if not self.musicManager.isValid():
|
||||
self.wantMusic=None
|
||||
|
||||
self.wantAnySound = (self.wantSfx or self.wantMusic)
|
||||
|
||||
def loadSfx(self, name):
|
||||
if (name and base.wantSfx):
|
||||
if (name):
|
||||
sound=self.sfxManager.getSound(name)
|
||||
if sound == None:
|
||||
self.notify.warning("Could not load sound file %s." % name)
|
||||
return sound
|
||||
|
||||
def loadMusic(self, name):
|
||||
if (name and base.wantMusic):
|
||||
if (name):
|
||||
sound=self.musicManager.getSound(name)
|
||||
if sound == None:
|
||||
self.notify.warning("Could not load music file %s." % name)
|
||||
@ -357,7 +352,7 @@ class ShowBase:
|
||||
|
||||
def playSfx(self, sfx, looping = 0, interupt = 1, volume = None,
|
||||
time = 0.):
|
||||
if (sfx and base.wantSfx):
|
||||
if sfx:
|
||||
if volume != None:
|
||||
sfx.setVolume(volume)
|
||||
if interupt or (sfx.status() != AudioSound.PLAYING):
|
||||
@ -367,7 +362,7 @@ class ShowBase:
|
||||
|
||||
def playMusic(self, music, looping = 0, interupt = 1, volume = None,
|
||||
time = 0.0):
|
||||
if (music and base.wantMusic):
|
||||
if music:
|
||||
if volume != None:
|
||||
music.setVolume(volume)
|
||||
if interupt or (music.status() != AudioSound.PLAYING):
|
||||
@ -376,11 +371,11 @@ class ShowBase:
|
||||
music.play()
|
||||
|
||||
def stopSfx(self, sfx):
|
||||
if (sfx and base.wantSfx):
|
||||
if sfx:
|
||||
sfx.stop()
|
||||
|
||||
def stopMusic(self, music):
|
||||
if (music and base.wantMusic):
|
||||
if music:
|
||||
music.stop()
|
||||
|
||||
def dataloop(self, state):
|
||||
@ -702,64 +697,40 @@ class ShowBase:
|
||||
|
||||
# these are meant to be called in response to a user request
|
||||
def EnableMusic(self, bEnableMusic):
|
||||
self.wantMusic = bEnableMusic
|
||||
self.wantAnySound = (self.wantSfx or self.wantMusic)
|
||||
|
||||
if (self.wantMusic and self.musicManager == None):
|
||||
self.createAudioManager()
|
||||
|
||||
if not self.wantMusic:
|
||||
# Oops, it didn't work.
|
||||
self.notify.warning("Unable to toggle music on.")
|
||||
return 0
|
||||
|
||||
# dont setActive(1) if no audiofocus
|
||||
if(not (self.wantMusic and not self.AppHasAudioFocus)):
|
||||
self.musicManager.setActive(self.wantMusic)
|
||||
|
||||
if(self.wantMusic):
|
||||
if self.AppHasAudioFocus and self.musicManagerIsValid:
|
||||
self.musicManager.setActive(bEnableMusic)
|
||||
self.musicActive = bEnableMusic
|
||||
if bEnableMusic:
|
||||
self.notify.debug("Enabling music")
|
||||
else:
|
||||
self.notify.debug("Disabling music")
|
||||
return 1
|
||||
|
||||
def EnableSoundEffects(self, bEnableSoundEffects):
|
||||
self.wantSfx = bEnableSoundEffects
|
||||
self.wantAnySound = (self.wantSfx or self.wantMusic)
|
||||
|
||||
if (self.wantSfx and self.sfxManager == None):
|
||||
self.createAudioManager()
|
||||
|
||||
if not self.wantSfx:
|
||||
# Oops, it didn't work.
|
||||
self.notify.warning("Unable to toggle sound effects on.")
|
||||
return 0
|
||||
|
||||
# dont setActive(1) if no audiofocus
|
||||
if(not (self.wantSfx and not self.AppHasAudioFocus)):
|
||||
self.sfxManager.setActive(self.wantSfx)
|
||||
|
||||
if(self.wantSfx):
|
||||
if self.AppHasAudioFocus and self.sfxManagerIsValid:
|
||||
self.sfxManager.setActive(bEnableSoundEffects)
|
||||
self.sfxActive=bEnableSoundEffects
|
||||
if bEnableSoundEffects:
|
||||
self.notify.debug("Enabling sound effects")
|
||||
else:
|
||||
self.notify.debug("Disabling sound effects")
|
||||
return 1
|
||||
|
||||
# these are meant to be called by the sw when app loses audio focus (switched out)
|
||||
def DisableAudio(self):
|
||||
self.AppHasAudioFocus = 0
|
||||
if (self.wantSfx and (self.sfxManager != None)):
|
||||
if self.sfxManagerIsValid:
|
||||
self.sfxManager.setActive(0)
|
||||
if (self.wantMusic and (self.musicManager != None)):
|
||||
if self.musicManagerIsValid:
|
||||
self.musicManager.setActive(0)
|
||||
self.notify.debug("Disabling audio")
|
||||
|
||||
def EnableAudio(self):
|
||||
self.AppHasAudioFocus = 1
|
||||
if (self.wantSfx and (self.sfxManager != None)):
|
||||
self.sfxManager.setActive(1)
|
||||
if (self.wantMusic and (self.musicManager != None)):
|
||||
self.musicManager.setActive(1)
|
||||
if self.sfxManagerIsValid:
|
||||
self.sfxManager.setActive(self.sfxActive)
|
||||
if self.musicManagerIsValid:
|
||||
self.musicManager.setActive(self.musicActive)
|
||||
self.notify.debug("Enabling audio")
|
||||
|
||||
def run(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user