Browse Source

integrate gui sound fixes from community member Bruce Smith

David Rose 14 years ago
parent
commit
f1c5c8ecaf

+ 0 - 6
direct/src/gui/DirectGuiGlobals.py

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

+ 5 - 2
direct/src/gui/DirectOptionMenu.py

@@ -57,8 +57,11 @@ class DirectOptionMenu(DirectButton):
         # Check if item is highlighted on release and select it if it is
         # Check if item is highlighted on release and select it if it is
         self.popupMarker.bind(DGG.B1RELEASE, self.selectHighlightedIndex)
         self.popupMarker.bind(DGG.B1RELEASE, self.selectHighlightedIndex)
         # Make popup marker have the same click sound
         # 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
         # This is created when you set the menu's items
         self.popupMenu = None
         self.popupMenu = None
         self.selectedIndex = None
         self.selectedIndex = None

+ 6 - 1
direct/src/showbase/ShowBase.py

@@ -199,7 +199,6 @@ class ShowBase(DirectObject.DirectObject):
         # stores a CollisionTraverser pointer here, we'll traverse it
         # stores a CollisionTraverser pointer here, we'll traverse it
         # in the collisionLoop task.
         # in the collisionLoop task.
         self.shadowTrav = 0
         self.shadowTrav = 0
-        # in the collisionLoop task.
         self.cTrav = 0
         self.cTrav = 0
         self.cTravStack = Stack()
         self.cTravStack = Stack()
         # Ditto for an AppTraverser.
         # Ditto for an AppTraverser.
@@ -351,6 +350,12 @@ class ShowBase(DirectObject.DirectObject):
                 # dict of guiId to gui item, for tracking down leaks
                 # dict of guiId to gui item, for tracking down leaks
                 self.guiItems = {}
                 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
         # Now hang a hook on the window-event from Panda.  This allows
         # us to detect when the user resizes, minimizes, or closes the
         # us to detect when the user resizes, minimizes, or closes the
         # main window.
         # main window.