integrate gui sound fixes from community member Bruce Smith

This commit is contained in:
David Rose 2011-11-02 21:13:03 +00:00
parent 165fa85a4e
commit f1c5c8ecaf
3 changed files with 11 additions and 9 deletions

View File

@ -103,9 +103,6 @@ BUTTON_ROLLOVER_STATE = PGButton.SRollover # 2
BUTTON_INACTIVE_STATE = PGButton.SInactive # 3
def getDefaultRolloverSound():
global defaultRolloverSound
if defaultRolloverSound == None:
defaultRolloverSound = base.loadSfx("audio/sfx/GUI_rollover.wav")
return defaultRolloverSound
def setDefaultRolloverSound(newSound):
@ -113,9 +110,6 @@ def setDefaultRolloverSound(newSound):
defaultRolloverSound = newSound
def getDefaultClickSound():
global defaultClickSound
if defaultClickSound == None:
defaultClickSound = base.loadSfx("audio/sfx/GUI_click.wav")
return defaultClickSound
def setDefaultClickSound(newSound):

View File

@ -57,8 +57,11 @@ class DirectOptionMenu(DirectButton):
# Check if item is highlighted on release and select it if it is
self.popupMarker.bind(DGG.B1RELEASE, self.selectHighlightedIndex)
# Make popup marker have the same click sound
self.popupMarker.guiItem.setSound(
DGG.B1PRESS + self.popupMarker.guiId, self['clickSound'])
if self['clickSound']:
self.popupMarker.guiItem.setSound(
DGG.B1PRESS + self.popupMarker.guiId, self['clickSound'])
else:
self.popupMarker.guiItem.clearSound(DGG.B1PRESS + self.popupMarker.guiId)
# This is created when you set the menu's items
self.popupMenu = None
self.selectedIndex = None

View File

@ -199,7 +199,6 @@ class ShowBase(DirectObject.DirectObject):
# stores a CollisionTraverser pointer here, we'll traverse it
# in the collisionLoop task.
self.shadowTrav = 0
# in the collisionLoop task.
self.cTrav = 0
self.cTravStack = Stack()
# Ditto for an AppTraverser.
@ -351,6 +350,12 @@ class ShowBase(DirectObject.DirectObject):
# dict of guiId to gui item, for tracking down leaks
self.guiItems = {}
# optionally restore the default gui sounds from 1.7.2 and earlier
if ConfigVariableBool('orig-gui-sounds', False).getValue():
from direct.gui import DirectGuiGlobals as DGG
DGG.setDefaultClickSound(self.loader.loadSfx("audio/sfx/GUI_click.wav"))
DGG.setDefaultRolloverSound(self.loader.loadSfx("audio/sfx/GUI_rollover.wav"))
# Now hang a hook on the window-event from Panda. This allows
# us to detect when the user resizes, minimizes, or closes the
# main window.