Esempio n. 1
0
LOCAL void Story_OnKey(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
	if (vk == VK_ESCAPE)
	{
		PSTORY pStory = GetStory(hWindow);
		if (pStory && pStory->m_fPlaying)
			MCIStop(pStory->m_hMCIfile);
	}
}
Esempio n. 2
0
void CStory::StopPlaying()
/***********************************************************************/
{
	if (m_hMCIfile)
	{
		if (m_fPlaying)
		{
			MCIStop(m_hMCIfile, TRUE);
			Reset();
		}
	}
}
Esempio n. 3
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;
		}
	}
}
Esempio n. 4
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;
	}
}
Esempio n. 5
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;
}
Esempio n. 6
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;
			}
		}
	}
}
Esempio n. 7
0
void Video_GotoShot( HWND hWindow, LPVIDEO lpVideo, SHOTID lShot, long lCount, int iFrames, int iEventCode )
/***********************************************************************/
{
	LPSHOT lpShot;

	if ( !(lpShot = Video_GetShot( lpVideo, lShot, lCount )) )
	{
		MCIStop( lpVideo->hDevice, YES/*bWait*/ );
		MCIPlay( lpVideo->hDevice, hWindow/*Notify Myself*/ );
		return;
	}

	if ( lpShot->wDisk != lpVideo->wDisk )
		if ( !Video_Open( hWindow, lpVideo, lpShot->wDisk, lpShot->lStartFrame ) )
			return;

	if ( lpShot->lShotID != lpVideo->lCurrentShot || !iEventCode )
	{ // if the shot is changing, or a NULL event code...

		// Send the notification message if the shot is changing
		lpShot->iLastEvent = iEventCode;
		LPPSHOT lppShot = &lpShot;
		FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow),
			LOWORD(lppShot), HIWORD(lppShot), SendMessage );
		if ( !(*lppShot) ) // if the application rejects this shot...
			return; // get out, and whatever is playing keeps playing

		// Set the previous shot variables, unless we could cause an infinite loop
		if ( lpShot->bGoesPrev )
		{
			LPSHOT lpCurrentShot = Video_GetShotPtr( lpVideo, lpVideo->lCurrentShot );
			if ( lpCurrentShot && !lpCurrentShot->bGoesPrev )
			{
				lpVideo->lPrevFrame = MCIGetPosition( lpVideo->hDevice );
				lpVideo->lPrevShot = lpVideo->lCurrentShot;
			}
		}
			
		lpVideo->lCurrentShot = lpShot->lShotID;
	}

	// Calculate the lFrom and lTo frames
	long lTo = lpShot->lEndFrame;
	long lFrom = lpShot->lStartFrame;
	if ( iFrames > 0 )
		lFrom = max( lTo - iFrames, lFrom );

	if ( lpShot->lIndentFrames )
	{ // If indention is being used...
		lFrom += lpShot->lIndentFrames;
		lpShot->lIndentFrames = 0;
		if ( lFrom > lTo )
			lFrom = lTo;
	}
	else // Clear any disabled hotspot flags
		Video_ShotEnableHotspots( lpVideo, lpShot );

	MCIStop( lpVideo->hDevice, YES/*bWait*/ );
	MCIPlay( lpVideo->hDevice, hWindow/*Notify Myself*/, lFrom, lTo );
	lpVideo->lLastShotToPlay = lpVideo->lCurrentShot;
}
Esempio n. 8
0
static void Video_OnKey(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
	BOOL bReturn;
	LPVIDEO lpVideo;
	static int iSpeed;

	if ( StyleOn( hWindow, WS_NOTENABLED ) )
		return;

	#ifndef _DEBUG
	if ( flags & KF_REPEAT )
		return;
	#endif

	if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) )
		return;

	switch ( vk )
	{
		case 'P':
		{ // Play
			Video_GotoShot( hWindow, lpVideo, lpVideo->lCurrentShot,
				1/*lCount*/, 0/*iFrames*/, 0/*iEventCode*/ );
			break;
		}

		case 'S':
		{ // Stop
			if (lpVideo->idLoopTimer)
			{
				KillTimer (hWindow, lpVideo->idLoopTimer);
				lpVideo->idLoopTimer = NULL;
			}
			bReturn = MCIStop( lpVideo->hDevice, YES/*bWait*/ );
			break;
		}

		case VK_PAUSE:
		{
			DWORD dwMode = MCIGetMode( lpVideo->hDevice );
			if ( dwMode == MCI_MODE_PAUSE )
				bReturn = MCIResume( lpVideo->hDevice );
			else
			if ( dwMode == MCI_MODE_PLAY )
				bReturn = MCIPause( lpVideo->hDevice );
			break;
		}

		case VK_SPACE:
		{ // Process the END event to skip the current shot
			Video_ProcessEvent( hWindow, lpVideo, EVENT_END );
			break;
		}

		case VK_LEFT:
		{ // Process the LEFT event
			Video_ProcessEvent( hWindow, lpVideo, EVENT_LEFT );
			break;
		}

		case VK_UP:			
		{ // Process the UP event
			Video_ProcessEvent( hWindow, lpVideo, EVENT_UP );
			break;
		}
		
		case VK_RIGHT:
		{ // Process the RIGHT event
			Video_ProcessEvent( hWindow, lpVideo, EVENT_RIGHT );
			break;
		}

		case VK_DOWN:
		{ // Process the DOWN event
			Video_ProcessEvent( hWindow, lpVideo, EVENT_DOWN );
			break;
		}

		case VK_HOME:
		{ // Process the DOWN event
			Video_ProcessEvent( hWindow, lpVideo, EVENT_HOME );
			break;
		}

		#ifdef _DEBUG
		case '1':
		{
			bReturn = MCISetAudioOnOff( lpVideo->hDevice, OFF );
			break;
		}

		case '2':
		{
			bReturn = MCISetAudioOnOff( lpVideo->hDevice, ON );
			break;
		}

		case '3':
		{
			bReturn = MCISetVideoOnOff( lpVideo->hDevice, OFF );
			break;
		}

		case '4':
		{
			bReturn = MCISetVideoOnOff( lpVideo->hDevice, ON );
			break;
		}

		case 'G':	// Turn grid draw proc on
		{
			Video_DrawProcInstall( hWindow, VDP_GridSet, VDP_GridDraw, 33 );
			break;
		}

		case 'H':	// Turn hotspot draw proc on
		{
			Video_DrawProcInstall( hWindow, VDP_HotspotSet, VDP_HotspotDraw, 33 );
			break;
		}

		case 'N':	// Turn draw proc off
		{
			Video_DrawProcInstall( hWindow, NULL, NULL, 33 );
			break;
		}

//		case VK_HOME:
//		{
//			bReturn = MCISeekHome( lpVideo->hDevice );
//			break;
//		}

		case VK_END:
		{
			LPSHOT lpShot = Video_GetShotPtr( lpVideo, lpVideo->lCurrentShot );
			if ( lpShot )
				bReturn = MCISeek( lpVideo->hDevice, lpShot->lEndFrame );
			else
				bReturn = MCISeekEnd( lpVideo->hDevice );
			break;
		}

		case VK_NEXT:
		{
			bReturn = MCIStepForward( lpVideo->hDevice, 1 );
			break;
		}

		case VK_PRIOR:
		{
			bReturn = MCIStepReverse( lpVideo->hDevice );
			break;
		}

		case VK_MULTIPLY:
		{
			iSpeed = 0;
			bReturn = MCISetVideoSpeed( lpVideo->hDevice, 1000L + iSpeed );
			break;
		}

		case VK_ADD:
		{
			if ( iSpeed >= 1000 )
				break;
			iSpeed += 100;
			bReturn = MCISetVideoSpeed( lpVideo->hDevice, 1000L + iSpeed );
			break;
		}

		case VK_SUBTRACT:
		{
			if ( iSpeed <= -1000 )
				break;
			iSpeed -= 100;
			bReturn = MCISetVideoSpeed( lpVideo->hDevice, 1000L + iSpeed );
			break;
		}
		#endif

		default:
			break;
	}

	#ifdef _DEBUG // For putting the current frame number into a text box
		STRING szString;
		wsprintf( szString, "%ld", MCIGetPosition( lpVideo->hDevice ) );
		SetDlgItemText( GetParent(hWindow), 120/*IDC_VIDEO_SHOTFRAME*/, szString );
	#endif
}
Esempio n. 9
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;
			}
		}
	}
}