some more tools

This commit is contained in:
Cary Sandvig 2001-04-23 20:49:34 +00:00
parent f87ee668fc
commit 25a987f9c8
3 changed files with 34 additions and 0 deletions

View File

@ -78,3 +78,22 @@ INLINE void AudioPool::release_all_sounds(void) {
// in the universe and it constructs itself.
////////////////////////////////////////////////////////////////////
INLINE AudioPool::AudioPool(void) {}
////////////////////////////////////////////////////////////////////
// Function: AudioPool::get_num_loaded_sounds
// Access: Public, static
// Description: return the number of sounds the audiopool thinks
// are loaded at the moment
////////////////////////////////////////////////////////////////////
INLINE int AudioPool::get_num_loaded_sounds(void) {
return get_ptr()->_sounds.size();
}
////////////////////////////////////////////////////////////////////
// Function: AudioPool::get_nth_sound_name
// Access: Public, static
// Description: return the name of the nth loaded sound
////////////////////////////////////////////////////////////////////
INLINE string AudioPool::get_nth_sound_name(int n) {
return get_ptr()->ns_get_nth_sound_name(n);
}

View File

@ -151,3 +151,15 @@ void AudioPool::register_sound_loader(const string& ext,
}
(*_sound_loaders)[ext] = func;
}
////////////////////////////////////////////////////////////////////
// Function: AudioPool::ns_get_nth_sound_name
// Access: Public
// Description: return the name of the nth loaded sound
////////////////////////////////////////////////////////////////////
string AudioPool::ns_get_nth_sound_name(int n) const {
SoundMap::const_iterator i;
int j;
for (i=_sounds.begin(), j=0; j<n; ++i, ++j);
return (*i).first;
}

View File

@ -22,6 +22,7 @@ private:
AudioSound* ns_load_sound(Filename filename);
void ns_release_sound(AudioSound* sound);
void ns_release_all_sounds(void);
string ns_get_nth_sound_name(int) const;
static AudioPool* get_ptr(void);
@ -37,6 +38,8 @@ PUBLISHED:
INLINE static AudioSound* load_sound(const string& filename);
INLINE static void release_sound(AudioSound* sound);
INLINE static void release_all_sounds(void);
INLINE static int get_num_loaded_sounds(void);
INLINE static string get_nth_sound_name(int);
static void register_sound_loader(const string&, SoundLoadFunc*);
};