Ejemplo n.º 1
0
// Start and stop the midi file
//************************************************************************
static void StartMidi( BOOL bTurnOn )
//************************************************************************
{
	static HMCI hPlayMidi;

	if ( !bTurnOn )
	{ // turn the sound off
		if ( hPlayMidi )
		{ // If playing, stop it
			MCIClose( hPlayMidi );
			hPlayMidi = NULL;
		}
	}
	else
	{ // turn the sound on
		if ( hPlayMidi )
			return;	// If already playing, return

		if ( hPlayMidi = MCIOpen (GetApp()->m_hDeviceMID, TEST_MIDI, NULL/*lpAlias*/) )
		{
			MCILoop( hPlayMidi, TRUE );
			if ( !MCIPlay( hPlayMidi, GetApp()->GetMainWnd() ) )
			{
				MCIClose( hPlayMidi );
				hPlayMidi = NULL;
			}
		}
	}
}
Ejemplo n.º 2
0
// Start and stop the wave file
//************************************************************************
static void StartWave( BOOL bTurnOn )
//************************************************************************
{
	static HMCI hPlayWave;

	if ( !bTurnOn )
	{ // turn the sound off
		if ( hPlayWave )
		{ // If playing, stop it
			MCIClose( hPlayWave );
			hPlayWave = NULL;
		}
	}
	else
	{ // turn the sound on
		if ( hPlayWave )
			return;	// If already playing, return

		if ( hPlayWave = MCIOpen (GetApp()->m_hDeviceWAV, TEST_WAVE, NULL/*lpAlias*/) )
		{
			MCILoop( hPlayWave, TRUE );
			if ( !MCIPlay( hPlayWave, GetApp()->GetMainWnd() ) )
			{
				MCIClose( hPlayWave );
				hPlayWave = NULL;
			}
		}
	}
}
Ejemplo n.º 3
0
BOOL CScene::OnInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
/************************************************************************/
{
	// Force the caption flag off for win95
	DWORD dwStyle = GetWindowLong( hWnd, GWL_STYLE );
	SetWindowLong( hWnd, GWL_STYLE, dwStyle & (~WS_CAPTION) );

	// Get the command string
	STRING szString;
	GetWindowText( hWnd, szString, sizeof(STRING)-1 );
	FNAME szMidi;
	GetStringParm( szString, 1/*nIndex*/, ',', szMidi );
	LPLONG lpSwitches = ExtractSwitches( szString );

	// Create the sound class with or w/o wavemix
	m_pSound = new CSound((BOOL)GetSwitchValue( 'w', lpSwitches));
	if (m_pSound)
		m_pSound->Open( NULL/*"powersnd.dll"*/ );

	if ( lpSwitches )
		FreeUp( (LPTR)lpSwitches );

	// Fix the coordinates from the resource file
	RepositionDialogControls( hWnd );

	// Center the scene within the app's client area
	CenterWindow( hWnd );

	// This should not be necessary, since it's done in the OnClose()
	if ( m_hMidiTheme )
	{ // close any looping midi theme
		MCIClose( m_hMidiTheme );
		m_hMidiTheme = NULL;
	}

	if ( *szMidi )
	{ // The scene has a midi theme, so start it
		LPLONG lpMidiSwitches = ExtractSwitches( szMidi );
		if ( m_hMidiTheme = MCIOpen( GetApp()->m_hDeviceMID, szMidi, NULL/*lpAlias*/ ) )
		{
			if ( lpMidiSwitches )
				MCILoop( m_hMidiTheme, (BOOL)GetSwitchValue( 'l', lpMidiSwitches ) );
			if ( !MCIPlay( m_hMidiTheme, GetApp()->GetMainWnd() ) )
			{
				MCIClose( m_hMidiTheme );
				m_hMidiTheme = NULL;
			} // if it's not looping, it will close itself when it ends
		}
		if ( lpMidiSwitches )
			FreeUp( (LPTR)lpMidiSwitches );
	}

	// if we have an animation object then setup a timer for it
	m_idAnimatorTimer = SetTimer(hWnd, ANIMATOR_TIMER_ID, 1, NULL);

	return(TRUE);
}
Ejemplo n.º 4
0
BOOL CStory::Play()
/***********************************************************************/
{
	// returns TRUE if it started playing
	if (lstrlen(m_szStoryFile))
		m_hMCIfile = MCIOpen( App.m_hDeviceWAV, m_szStoryFile, NULL/*lpAlias*/ );
	if (m_hMCIfile)
	{
		if (m_nRects)  
		{
			HDC hDC = GetDC(m_hWnd);
			m_iHighlight = 0 + 1;
			Story_OnDraw(m_hWnd, hDC, &m_lpWordData[0].rArea, TRUE);
			ReleaseDC(m_hWnd, hDC);
		}
		if (MCIPlay( m_hMCIfile, m_hWnd, 0))
		{
			EnableCursor(FALSE);
			m_fPlaying = TRUE;
			SetTimer( m_hWnd, 0xDEAD, 5, NULL );
			return(TRUE);
		}
		else
		{
			MCIClose( m_hMCIfile );
			m_hMCIfile = NULL;
		}
	}
	return(FALSE);
}
Ejemplo n.º 5
0
//************************************************************************
void CBelongsScene::ToonInitDone()
//************************************************************************
{
	STRING szName;

	ShowDlgItem(m_hWnd, IDC_EDIT, TRUE);
	UpdateWindow(GetDlgItem(m_hWnd, IDC_EDIT));
	SetFocus(GetDlgItem(m_hWnd, IDC_EDIT));
	//GetApp()->GetSettingString("Name", szName, "", FALSE);
	szName[0] = '\0';
	if (lstrlen(szName))
	{
		SetDlgItemText(m_hWnd, IDC_EDIT, szName);
		Edit_SetSel(GetDlgItem(m_hWnd, IDC_EDIT), 0, -1);
		Edit_SetSel(GetDlgItem(m_hWnd, IDC_EDIT), -1, 0);
		UpdateWindow(GetDlgItem(m_hWnd, IDC_EDIT));
		PlayBelongsTo(NO);
		FORWARD_WM_COMMAND(m_hWnd, IDC_NEXT, m_hWnd, 0, PostMessage);
	}
	else
	{
		FNAME szFileName;

		GetPathName(szFileName, ENTER_NAME_WAVE);
		if (m_hSound)
		{
			MCIStop(m_hSound,YES);
			MCIClose(m_hSound);
			m_hSound = NULL;
		}
		m_hSound = MCIOpen(GetApp()->m_hDeviceWAV, szFileName, NULL); 
		if (m_hSound)
		{
			if (!MCIPlay(m_hSound, m_hWnd))
			{
				MCIClose(m_hSound);
				m_hSound = NULL;
			}
		}
	}
}
Ejemplo n.º 6
0
//************************************************************************
void CScene::OnClose(HWND hWnd)
//************************************************************************
{
	if ( m_hMidiTheme )
	{ // close any looping midi theme
		MCIClose( m_hMidiTheme );
		m_hMidiTheme = NULL;
	}
	GetApp()->m_bAppNoErase = m_bSceneNoErase = m_bNoErase; // don't want the app background to paint in between
	GetApp()->ResetJoyMap();
	DialogEnd( hWnd, TRUE );
}
Ejemplo n.º 7
0
CStory::~CStory()
/***********************************************************************/
{
	if (m_hMCIfile)
		MCIClose(m_hMCIfile);
	if (m_pDib)
		delete m_pDib;
	if (m_lpWordData)
		FreeUp(m_lpWordData);
	if (m_hHotSpotCursor)
		DestroyCursor(m_hHotSpotCursor);
}
Ejemplo n.º 8
0
//************************************************************************
UINT CBelongsScene::OnMCINotify(HWND hWnd, UINT message, HMCI hDeviceID)
//************************************************************************
{

	if ( message != MCI_NOTIFY_SUCCESSFUL	&&
		 message != MCI_NOTIFY_ABORTED		&&
		 message != MCI_NOTIFY_SUPERSEDED	&&
		 message != MCI_NOTIFY_FAILURE )
			return FALSE;

	MCIClose(m_hSound);
	m_hSound = NULL;
	return TRUE;
}		
Ejemplo n.º 9
0
//************************************************************************
void CBelongsScene::OnCommand(HWND hWnd, int id, HWND hControl, UINT codeNotify)
//************************************************************************
{
	switch (id)
	{
		case IDC_EDIT:
		{
			if (codeNotify == EN_CHANGE)
			{
			}
			break;
		}

#ifdef _DEBUG
		case VK_SPACE:
		{
			PlayBelongsTo(YES);
			SetDlgItemText(hWnd, IDC_EDIT, "");
			break;
		}
#endif

		case IDC_PLAYBELONGS:
		{
			EnableWindow(GetDlgItem(hWnd, IDC_EDIT), FALSE);
			PlayBelongsTo(NO);
			FORWARD_WM_COMMAND(m_hWnd, IDC_NEXT, m_hWnd, 0, PostMessage);
			break;
		}

		case IDC_NEXT:
		{
			if (m_hSound)
			{
				MCIStop(m_hSound,YES);
				MCIClose(m_hSound);
				m_hSound = NULL;
			}
			ShowDlgItem(hWnd, IDC_EDIT, FALSE);
			UpdateWindow(hWnd);
		}

		default:
		{
			CGBScene::OnCommand(hWnd, id, hControl, codeNotify);
			break;
		}
	}
}
Ejemplo n.º 10
0
//************************************************************************
void CBelongsScene::OnDestroy(HWND hWnd)
//************************************************************************
{
	STRING szString;
	GetDlgItemText(hWnd, IDC_EDIT, szString, sizeof(szString));
	StripLeadingSpaces(szString);
	GetApp()->WriteSettingString("Name", szString, FALSE);
	CGBScene::OnDestroy(hWnd);
	if (m_hSound)
	{
		MCIStop(m_hSound,YES);
		MCIClose(m_hSound);
		m_hSound = NULL;
	}
}
Ejemplo n.º 11
0
static void Video_Close( HWND hWindow, LPVIDEO lpVideo )
/***********************************************************************/
{
	if ( !lpVideo )
		return;

	if ( lpVideo->hDevice )
	{
		MCIStop( lpVideo->hDevice, YES/*bWait*/ );
		// The MCIClose() line below causes 2 mmtask errors: even Media Player gets them
		// mmtask: Invalid global handle 0x0000
		// mmtask: CreateDC error
		HMCI hDevice = lpVideo->hDevice;
		lpVideo->hDevice = NULL;
		MCIClose( hDevice );
//		InvalidateRect( hWindow, NULL, TRUE );
//		UpdateWindow( hWindow );
	}
	lpVideo->wDisk = 0;
}
Ejemplo n.º 12
0
void CStory::Reset()
/***********************************************************************/
{
	if (m_hMCIfile)
	{
		MCIClose( m_hMCIfile );
		m_hMCIfile = NULL;
	}
	if (m_fPlaying)
	{
		EnableCursor(TRUE);
		m_fPlaying = FALSE;
		KillTimer( m_hWnd, 0xDEAD );
		if (m_iHighlight)
		{
			HDC hDC = GetDC(m_hWnd);
			Story_OnDraw(m_hWnd, hDC, &m_lpWordData[m_iHighlight-1].rArea, FALSE);
			m_iHighlight = 0;
			ReleaseDC(m_hWnd, hDC);
		}
	}
}
Ejemplo n.º 13
0
LOCAL void Story_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags)
/***********************************************************************/
{
	if ( SHIFT )
		return;
	if ( bTrack )
		return;
	PSTORY pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (pStory->m_fPlaying)
		return;

	if (pStory->m_fPlaying)
		pStory->StopPlaying();
	SetCapture( hWindow ); bTrack = TRUE;
	if ( GetFocus() != hWindow )
		SetFocus( hWindow );
	bInRect = YES;
	DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE);
	int i;
	if ((i = pStory->FindHotSpot(x, y)) >= 0)
	{
		HDC hDC = GetDC(hWindow);
		pStory->m_iHighlight = i + 1;
		Story_OnDraw(hWindow, hDC, &pStory->m_lpWordData[i].rArea, TRUE);
		if (lstrlen(pStory->m_szStoryFile))
 			pStory->m_hMCIfile = MCIOpen( App.m_hDeviceWAV, pStory->m_szStoryFile, NULL/*lpAlias*/ );
		if ( pStory->m_hMCIfile )
		{
			FORWARD_WM_COMMAND(GetParent(hWindow), GET_WINDOW_ID(hWindow), hWindow, 0, SendMessage);
			MCIPlay( pStory->m_hMCIfile, NULL, pStory->m_lpWordData[i].dwFrom, pStory->m_lpWordData[i].dwTo );
			MCIClose( pStory->m_hMCIfile );
			pStory->m_hMCIfile = NULL;
		}
		ReleaseDC(hWindow, hDC);
	}
}
Ejemplo n.º 14
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;
			}
		}
	}
}