Sound *ResourceManager::NewSound(CTSTR lpName, BOOL b3DSound, BOOL bSelfDestruct) { traceInFast(ResourceManager::NewSound); assert(lpName); LPBYTE lpData = NULL; UINT val = SoundNames.FindValueIndexI(lpName); if(val != INVALID) lpData = SoundList[val]; if(!lpData) lpData = LoadSoundData(lpName); if(!lpData) { AppWarning(TEXT("Resource Manager: Could not create sound")); return NULL; } Sound *sound = SS->CreateSound(lpData, b3DSound, bSelfDestruct); if(sound) { sound->soundName = lpName; sound->b3DSound = b3DSound; } return sound; traceOutFast; }
BOOL ImportSound( HWND hwndParent, WND_DATA *pWndData ) { int n; BOOL bResult; OPENFILENAME ofn; CHAR szDirName[256], szFile[256], szFileTitle[256]; SOUND_DATA *psd; _fstrcpy( szDirName, szPath ); n = _fstrlen( szDirName ); if (n > 0) { if (szDirName[n-1] == '\\' ) { szDirName[n-1] = '\0'; } } szFile[0] = '\0'; _fmemset( &ofn, 0, sizeof(OPENFILENAME) ); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndParent; ofn.hInstance = hInst; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 1; ofn.lpstrFile= szFile; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.lpstrInitialDir = szDirName; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; bResult = GetOpenFileName( &ofn ); if ( !bResult ) { DWORD dwError; dwError = CommDlgExtendedError(); if ( dwError ) { MsgBox( hwndParent, MB_ICONEXCLAMATION, "Common dialog error %lu", dwError ); } return FALSE; } psd = &pWndData->pSoundData[pWndData->nSounds]; if ( LoadSoundData( hwndParent, psd, szFile ) == FALSE ) { return FALSE; } _fstrcpy( psd->sound_name, szFileTitle ); psd->flags = 0; ++pWndData->nSounds; return TRUE; } // ImportSound