// 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; } } } }
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); }
//************************************************************************ 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; } } } }
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); } }
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; }
//************************************************************************ 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; } } } }