Fixed some sound I forgot to exclude when refactoring this code.

This commit is contained in:
Storm Dragon 2025-03-11 21:15:24 -04:00
parent 0d9764abd9
commit 4aa3475ac4

View File

@ -93,21 +93,37 @@ class Sound:
except Exception as e:
print(f"Error loading sounds: {e}")
def get_sound_list(self, excludeDirs=None):
"""Get a list of available sounds, optionally excluding certain directories.
def get_sound_list(self, excludeDirs=None, includeSpecial=False):
"""Get a list of available sounds, optionally excluding certain directories and special sounds.
Args:
excludeDirs (list): List of directory names to exclude
includeSpecial (bool): Whether to include special sounds (logo, music_menu, etc.)
Returns:
list: List of sound keys
"""
if excludeDirs is None:
excludeDirs = self.excludedLearnDirs
# Filter sounds based on their directories
return [key for key, directory in self.soundDirectories.items()
if directory not in excludeDirs]
# Special sound names to exclude unless specifically requested
specialSounds = ["music_menu", "logo", "game-intro"]
# Filter sounds based on their directories and special names
filtered_sounds = []
for key, directory in self.soundDirectories.items():
# Skip sounds in excluded directories
if directory in excludeDirs:
continue
# Skip special sounds unless specifically requested
basename = key.split('/')[-1] # Get the filename without directory
if not includeSpecial and (basename in specialSounds or basename.startswith('_')):
continue
filtered_sounds.append(key)
return filtered_sounds
def play_bgm(self, music_file):
"""Play background music with proper volume.