//************************************************************************ BOOL CGBScene::PlaySound(LPCTSTR lpWaveFile, BOOL fHint) //************************************************************************ { LPSOUND pSound = GetSound(); if ( !pSound ) return( FALSE ); BOOL fRet; if ( !pSound->IsMixing() ) fRet = pSound->StartFile((LPSTR)lpWaveFile, FALSE/*bLoop*/, -1, TRUE/*bWait*/); else { // this nonsense is here because in order to make buttons // in action strip play the click wave when they are clicked // on we need to synchronously play the sound so the click // happens while the button is down. WaveMix does not play // sounds synchronously, so we deactivate WaveMix and use // sndPlaySound stuff. CSound sound; pSound->Activate(FALSE); fRet = sound.StartFile((LPSTR)lpWaveFile, FALSE/*bLoop*/, -1, TRUE/*bWait*/); pSound->Activate(TRUE); } return(fRet); }
//************************************************************************ void CNutDropScene::PlayLevelSuccessWave() //************************************************************************ { // Get the sound to play based on the level int iCount = 0; for (int i = 0 ; i < MAX_SUCCESSWAVES ; i++) { if (m_szSuccessLevel[i][0] != '\0') iCount++; } LPSTR lpWave; if (iCount <= 0) { lpWave = m_szSuccessLevel[0]; } else { i = GetRandomNumber (iCount); lpWave = m_szSuccessLevel[i]; } if (*lpWave != '\0') { FNAME szFileName; if (GetSound() ) { m_SoundPlaying = SuccessPlaying; GetSound()->StopChannel(NORMAL_CHANNEL); if (m_nSceneNo == IDD_NUTDROPI) { // Play this wave without wavemix LPSOUND lpSound = new CSound; if ( lpSound ) { GetSound()->Activate (FALSE); lpSound->StartFile( GetPathName(szFileName, lpWave), NO/*bLoop*/, NORMAL_CHANNEL/*iChannel*/, TRUE/*bWait*/, m_hWnd); delete lpSound; GetSound()->Activate (TRUE); FORWARD_WM_COMMAND (m_hWnd, IDC_NEXT, NULL, m_nNextSceneNo, PostMessage); } } else GetSound()->StartFile(GetPathName (szFileName, lpWave), NO/*bLoop*/, NORMAL_CHANNEL/*iChannel*/, FALSE/*bWait*/, m_hWnd); } } }
//************************************************************************ void OptionsSceneCommand( HWND hWnd, int id, HWND hControl, UINT codeNotify ) //************************************************************************ { UINT loWord = (UINT)hControl; UINT hiWord = codeNotify; LPSCENE lpScene = NULL; LPOFFSCREEN lpOffScreen = NULL; switch (id) { case IDC_OPTION1: case IDC_OPTION2: case IDC_OPTION3: case IDC_OPTION4: case IDC_OPTION5: { int i = id - (int)IDC_OPTION1; BOOL bState = !(1 & (int)SendDlgItemMessage(hWnd, id, SM_GETSTATE, 1, 0L)); SendDlgItemMessage(hWnd, IDC_OPTSTATE1+i, SM_SETSTATE, bState, 0L); SendDlgItemMessage(hWnd, id, SM_SETSTATE, bState, 0L); LPSOUND pSound = new CSound(); if (pSound) { pSound->StartResourceID( IDC_OPTSWITCH, NO/*bLoop*/, -1/*iChannel*/, GetApp()->GetInstance(), TRUE ); delete(pSound); } break; } case IDC_EXIT: case IDC_RETURN: { for (int i=0; i<MAX_OPTIONS; i++) bOption[i] = (BOOL)SendDlgItemMessage(hWnd, IDC_OPTION1+(i*2), SM_GETSTATE, 1, 0L); // Assign the options to the values being controlled App.bOptionTransitions = bOption[0]; App.bOptionAutoTarget = bOption[1]; App.bOptionFireBack = bOption[2]; App.bOptionMusic = bOption[3]; App.bOptionBarricades = bOption[4]; //App.bOptionTaunts = bOption[]; if ( App.bOptionsfromGame ) ResumeGame( hWnd, 0 ); else GetApp()->GotoScene (hWnd, 2); // Return to main screen break; } case IDC_VOLUME0: { //iVolumeState = SendDlgItemMessage( hWnd, IDC_VOLUME0, SM_GETSTATE, 0, 0L ); if (iVolumeState == 4) { iVolumeState = 0; SendDlgItemMessage( hWnd, IDC_VOLUME0, SM_SETSTATE, iVolumeState, 0L ); } else { iVolumeState++; SendDlgItemMessage( hWnd, IDC_VOLUME0, SM_SETSTATE, iVolumeState, 0L); } break; } case IDC_SLIDER_MIDIVOL: { // Start and stop the looping sound StartMidi( !loWord ); // loWord is 1, on slider up WORD wVolume = (WORD)(( 32767L * (DWORD)hiWord ) / 100L); MCISetVolume ((LPSTR)MCI_DEVTYPE_SEQUENCER, wVolume | 0x8000, wVolume | 0x8000); break; } case IDC_SLIDER_WAVVOL: { // Start and stop the looping sound StartWave( !loWord ); // loWord is 1, on slider up WORD wVolume = (WORD)(( 32767L * (DWORD)hiWord ) / 100L); MCISetVolume ((LPSTR)MCI_DEVTYPE_WAVEFORM_AUDIO, wVolume | 0x8000, wVolume | 0x8000); break; } default: break; } }