diff --git a/sound.py b/sound.py index 1271682..5dfb4c8 100644 --- a/sound.py +++ b/sound.py @@ -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.