69Get_INI (
const char *filename)
99 const char * delimiter,
108 if ((buffer !=
NULL) &&
109 (delimiter !=
NULL) &&
110 (string_list !=
NULL))
112 int delim_len = ::strlen (delimiter);
117 for (
const char *entry = buffer;
118 (entry !=
NULL) && (entry[1] != 0);
119 entry = ::strstr (entry, delimiter))
125 if ((::strnicmp (entry, delimiter, delim_len) == 0) && (count > 0)) {
145 (entry !=
NULL) && (entry[1] != 0);
146 entry = ::strstr (entry, delimiter))
152 if ((::strnicmp (entry, delimiter, delim_len) == 0) && (count > 0)) {
160 char *delim_start = ::strstr (entry_string, delimiter);
161 if (delim_start !=
NULL) {
168 if ((entry_string.
Get_Length () > 0) || (count == 0)) {
169 (*string_list)[count++] = entry_string;
173 }
else if (delim_len > 0) {
176 (*string_list)[0] = buffer;
193 const char *param_to_check
200 if ( param_list ==
NULL )
205 if ( param_count < 2 )
210 if ( param_to_check ==
NULL )
218 for (
int param_index = 2; param_index < param_count; param_index ++ )
230 if ( strstr(
string.Peek_Buffer(), param_to_check ) != 0 )
251 if (AnimSoundLists.Count () > 0) {
255 const char *DEFAULT_INI_FILENAME =
"w3danimsound.ini";
260 const char *filename_to_use = ini_filename;
261 if (filename_to_use ==
NULL) {
262 filename_to_use = DEFAULT_INI_FILENAME;
268 INIClass *ini_file = ::Get_INI (filename_to_use);
269 if (ini_file !=
NULL) {
276 section !=
NULL && section->Is_Valid ();
277 section = section->Next_Valid ())
292 ANIM_SOUND_LIST *sound_list =
new ANIM_SOUND_LIST;
297 int entry_count = ini_file->
Entry_Count (section->Section);
299 for (
int entry_index = 0; entry_index < entry_count; entry_index ++) {
305 const char *entry_name = ini_file->
Get_Entry (section->Section, entry_index);
311 if (strcmp(entry_name,
"BoneName") == 0) {
313 sound_list->BoneName =
value;
329 int len =
value.Get_Length ();
331 int action_frame = 0;
337 int param_count = ::Build_List_From_String (
value,
",", ¶m_list);
341 action_frame = ::atoi (param_list[0]);
342 definition_name = param_list[1];
343 definition_name.
Trim ();
349 ANIM_SOUND_INFO* sound_info =
new ANIM_SOUND_INFO;
350 sound_info->Frame = action_frame;
351 sound_info->SoundName = definition_name;
360 sound_info->Is2D =
false;
361 if ( Is_In_Param_List( param_list, param_count,
"2D" ) )
363 sound_info->Is2D =
true;
369 sound_info->IsStop =
false;
370 if ( Is_In_Param_List( param_list, param_count,
"STOP" ) )
372 sound_info->IsStop =
true;
375 sound_list->Add_Sound_Info (sound_info);
376 delete [] param_list;
381 if (sound_list->List.
Count () != 0) {
386 AnimationNameHash.Insert (animation_name, sound_list);
387 AnimSoundLists.Add (sound_list);
413 AnimationNameHash.Remove_All ();
418 for (
int index = 0; index < AnimSoundLists.Count (); index ++) {
425 delete AnimSoundLists[index];
428 AnimSoundLists.Delete_All ();
444 ANIM_SOUND_LIST* list = Find_Sound_List (anim);
459AnimatedSoundMgrClass::ANIM_SOUND_LIST *
460AnimatedSoundMgrClass::Find_Sound_List (
HAnimClass *anim)
471 ::strupr (full_name.Peek_Buffer ());
476 ANIM_SOUND_LIST *retval = AnimationNameHash.
Get (full_name);
495 if ((SoundLibrary ==
NULL) || (anim ==
NULL)) {
499 float retval = old_frame;
505 ANIM_SOUND_LIST *sound_list = Find_Sound_List (anim);
506 if (sound_list !=
NULL) {
508 for (
int index = 0; index < sound_list->List.
Count (); index ++) {
509 int frame = sound_list->List[index]->Frame;
514 if ((old_frame < frame) && (new_frame >= frame)) {
524 if (sound_list->List[index]->IsStop ==
true)
529 SoundLibrary->Stop_Playing_Audio( sound_list->List[index]->SoundName.Peek_Buffer() );
536 if (sound_list->List[index]->Is2D ==
true)
538 SoundLibrary->Play_2D_Audio(sound_list->List[index]->SoundName.Peek_Buffer());
542 SoundLibrary->Play_3D_Audio(sound_list->List[index]->SoundName.Peek_Buffer(), tm);
564 SoundLibrary = library;
static void Shutdown(void)
static void Set_Sound_Library(SoundLibraryBridgeClass *library)
static void Initialize(const char *ini_filename=NULL)
static const char * Get_Embedded_Sound_Name(HAnimClass *anim)
static float Trigger_Sound(HAnimClass *anim, float old_frame, float new_frame, const Matrix3D &tm)
virtual bool Is_Available(int forced=false)=0
virtual const char * Get_Name(void) const =0
ValueType Get(const KeyType &s) const
char const * Get_Entry(char const *section, int index) const
List< INISection * > & Get_Section_List()
int Get_String(char const *section, char const *entry, char const *defvalue, char *buffer, int size) const
int Entry_Count(char const *section) const
int Get_Length(void) const
TCHAR * Peek_Buffer(void)
FileFactoryClass * _TheFileFactory