示例#1
0
BOOL CLGBApp::FindContent( LPSTR lpFileName, LPSTR lpExpFileName )
/************************************************************************/
{
	if ( !lpFileName )
		return( FALSE );

	while ( TRUE )
	{
		STRING szString;

		// 1.) Try the file name as passed in
		if ( FileExistsExpand( lpFileName, lpExpFileName ) )
			return( TRUE );

		// 2.) Prompt to insert the CDROM disk...
		szString[0] = '\0';
		LoadString( GetInstance(), IDS_CDNAME, szString, sizeof(szString) );
		UINT uRet = PrintOKCancel( "Please insert '%s' CD-ROM.", (LPSTR)szString );
		if ( uRet == IDCANCEL )
			break;
		Delay( 5000L ); // wait in case the CD is not up to speed
	}
	//#ifdef _DEBUG
	Print("Cannot find file '%s'", lpFileName);
	//#endif

	// Post the close, so that we don't cause crashes
	// trying to execute code after windows have been
	// destroyed and classes have been destructed
	PostMessage( GetMainWnd(), WM_CLOSE, 0, 0L );

	return( FALSE );
}
示例#2
0
//************************************************************************
void CBelongsScene::PlayBelongsTo(BOOL fNameOnly)
//************************************************************************
{
	STRING szName;
	FNAME szNameWave;
	FNAME szFileName;
	BOOL fGotName = FALSE;

	GetDlgItemText(m_hWnd, IDC_EDIT, szName, sizeof(szName));
	StripLeadingSpaces(szName);
	if (!lstrlen(szName))
		return;

	// See if the name is in the table (for names longer than 8)
	STRING szTheName;
	int len = lstrlen(szName);
	for (int n = 0; n <= len; ++n)
	{
		if (isspace(szName[n]))
			szTheName[n] = '-';
		else
			szTheName[n] = szName[n];
	}

	for (int i = 0; i < m_nNames; ++i)
	{
		if (!lstrcmpi(m_pNames[i].m_szName, szTheName))
		{ // found it, now play the wav
			GetPathName(szNameWave, m_pNames[i].m_szFileName);
			fGotName = FileExistsExpand(szNameWave, NULL);
			break;
		}
	}

	// See if file for this name exists
	// in normal content directory
	if (!fGotName)
	{
		GetPathName(szNameWave, szName);
		lstrcat(szNameWave, ".wav");
		fGotName = FileExistsExpand(szNameWave, NULL);
	}
			
	// Try the windows directory for a custom name
	if (!fGotName)
	{
		GetWindowsDirectory(szNameWave, sizeof(szNameWave));
		FixPath(szNameWave);
		lstrcat(szNameWave, szName);
		lstrcat(szNameWave, ".wav");
		fGotName = FileExistsExpand(szNameWave, NULL);
	}

	if (fNameOnly && !fGotName)
		return;

	if (m_hSound)
	{
		MCIStop(m_hSound,YES);
		MCIClose(m_hSound);
		m_hSound = NULL;
	}

	if (!fNameOnly)
	{
		GetPathName(szFileName, BELONGS_TO_WAVE);
		if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL) )
		{
			MCIPlay(m_hSound, NULL);
			MCIClose(m_hSound);
			m_hSound = NULL;
		}
	}

	if (fGotName)
	{	// If we have a name play it
		if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szNameWave, NULL) )
		{
			MCIPlay(m_hSound, NULL);
			MCIClose(m_hSound);
			m_hSound = NULL;
		}
	}
	else
	{	// Otherwise, play it letter by letter
		STRING szName;
		GetDlgItemText(m_hWnd, IDC_EDIT, szName, sizeof(szName));
		StripLeadingSpaces(szName);

		STRING szLetter;
		FNAME szFileName;
		BOOL fExists = FALSE;
		int i = 0;
		char c;
		while ( c = szName[i++] )
		{
			szLetter[0] = c;
			szLetter[1] = '\0';
			lstrcat(szLetter, ".wav");
			GetPathName(szFileName, szLetter);
			if ( !FileExistsExpand(szFileName, NULL) )
				continue;
			if ( m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL) )
			{
				MCIPlay(m_hSound, NULL);
				MCIClose(m_hSound);
				m_hSound = NULL;
			}
		}
	}
}