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); }
CPuzzle::CPuzzle(HWND hWindow, HPALETTE hPal) /***********************************************************************/ { STRING szString; HWND hItem; m_hWnd = hWindow; m_pDib = NULL; m_iRows = 4; m_iCols = 4; m_iSelect = -1; m_szDibFile[0] = '\0'; m_bTrack = FALSE; m_bInRect = FALSE; m_hPal = hPal; m_idResource = GetDlgCtrlID(m_hWnd) + 1; m_bHintMode = FALSE; GetWindowText(hWindow, szString, sizeof(szString)); m_lpSwitches = ExtractSwitches(szString); #ifdef UNUSED GetModuleFileName(GetWindowInstance(hWindow), szFileName, sizeof(szFileName)); StripFile(szFileName); if (GetStringParm(szString, 0, ',', szFile)) { lstrcpy(m_szDibFile, szFileName); lstrcat(m_szDibFile, szFile); } if (lstrlen(m_szDibFile)) #endif HWND hParent = GetParent(m_hWnd); hItem = GetDlgItem(hParent, m_idResource); if (hItem) { GetWindowText(hItem, m_szDibFile, sizeof(m_szDibFile)); m_pDib = CDib::LoadDibFromFile( m_szDibFile, m_hPal, FALSE, TRUE ); } else m_pDib = CDib::LoadDibFromResource( GetWindowInstance(m_hWnd), MAKEINTRESOURCE(m_idResource), m_hPal, FALSE, TRUE ); if (m_pDib) Setup(); }
LOCAL BOOL Hotspot_OnCreate(HWND hWindow, LPCREATESTRUCT lpCreateStruct) /***********************************************************************/ { LPLONG lpSwitches; STRING szString; int iTimedSeconds; GetWindowText( hWindow, szString, sizeof(STRING) ); GetStringParm( szString, 0/*nIndex*/, ',', szString ); if ( lpSwitches = ExtractSwitches( szString ) ) { if ( iTimedSeconds = (int)GetSwitchValue( 't', lpSwitches ) ) { // Use the window handle as the timer id SetTimer( hWindow, (WORD)hWindow/*TimerID*/, 1000*iTimedSeconds, NULL ); } FreeUp( (LPTR)lpSwitches ); } return TRUE; }
static BOOL Video_Open( HWND hWindow, LPVIDEO lpVideo, WORD wDisk, long lStartFrame ) /***********************************************************************/ { if ( !lpVideo ) return( NO ); HourGlass( YES ); // Cleanup any open video file if ( lpVideo->lpSwitches ) { FreeUp( (LPTR)lpVideo->lpSwitches ); lpVideo->lpSwitches = NULL; } if ( lpVideo->idLoopTimer ) { KillTimer( hWindow, lpVideo->idLoopTimer ); lpVideo->idLoopTimer = NULL; } if ( lpVideo->hDevice ) { Video_Close( hWindow, lpVideo ); lpVideo->hDevice = NULL; } FNAME szFileName; GetWindowText( hWindow, szFileName, sizeof(STRING) ); GetStringParm( szFileName, 0/*nIndex*/, ',', szFileName ); lpVideo->lpSwitches = ExtractSwitches( szFileName ); // Replace any %d in the file name with the disk number, // and flag whether we need to check disk labels wsprintf( szFileName, szFileName, wDisk ); BOOL bFullScreen = (BOOL)GetSwitchValue( 'f', lpVideo->lpSwitches ); VideoInit( NO/*ZoomBy2*/, bFullScreen ); if ( !lpVideo->iZoomFactor ) { if ( iDefaultZoomFactor ) lpVideo->iZoomFactor = iDefaultZoomFactor; else { lpVideo->iZoomFactor = (int)GetSwitchValue( 'z', lpVideo->lpSwitches ); if ( !lpVideo->iZoomFactor ) lpVideo->iZoomFactor = 1; } } STRING szAlias; wsprintf( szAlias, "A%d%ld", wDisk, (LPSTR)hWindow ); if ( !(lpVideo->hDevice = MCIOpen( GetApp()->m_hDeviceAVI, szFileName, szAlias, hWindow, lStartFrame )) ) { HourGlass( NO ); return( NO ); } lpVideo->lFrames = MCIGetLength( lpVideo->hDevice ); lpVideo->wDisk = wDisk; //MCISetVideoDrawProc( lpVideo->hDevice, NULL/*lpDrawDibProc*/, NULL/*lpDrawDCProc*/ ); MCISetTimeFormat( lpVideo->hDevice, MCI_FORMAT_FRAMES ); // force the control to take on the size of the video file RECT rect; GetClientRect( hWindow, &rect ); MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rect, 2 ); SetWindowPos( hWindow, NULL, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER | SWP_NOACTIVATE ); HourGlass( NO ); return( YES ); }
void CScene::OnSize(HWND hWnd, UINT state, int cx, int cy) /***********************************************************************/ { STRING szString; FNAME szDib; PTOON pToon; // if there is a toon associated with this scene, there // is no need to create an offscreen, since a toon already // has all the offscreen functionality. if ( !(pToon = GetToon()) ) { // Instantiate the COffScreen object for this scene // if it has not already been done GetWindowText( hWnd, szString, sizeof(STRING)-1 ); GetStringParm( szString, 0/*nIndex*/, ',', szDib ); if ( !m_lpOffScreen ) { // /p switch sets up offscreen to use identity palette // created from the read-only dib instead of the // common application palette LPLONG lpSwitches = ExtractSwitches( szString ); if (GetSwitchValue('p', lpSwitches)) m_lpOffScreen = new COffScreen(); else m_lpOffScreen = new COffScreen(GetApp()->m_hPal); FreeUp(lpSwitches); } // if we don't have enough memory to instantiate // the offscreen, then we are done if ( !m_lpOffScreen ) return; // load the read-only background dib if it has not been done already if ( !m_lpOffScreen->GetReadOnlyDIB() ) { if ( *szDib ) m_lpOffScreen->Load( szDib ); else m_lpOffScreen->Load( GetWindowInstance(hWnd), m_nSceneNo ); // copy the colors to the stage dib to be used with WinG m_lpOffScreen->CopyColors(); } // if we were unsuccessful, then clean up and bail out if ( !m_lpOffScreen->GetReadOnlyDIB() ) { delete m_lpOffScreen; m_lpOffScreen = NULL; return; } // Resize the stage dib and create the WinG bitmap m_lpOffScreen->Resize( cx, cy ); // Copy bits from the read-only dib to the WinG bitmap m_lpOffScreen->CopyBits(); } // setup animator object to be used with sprite engine // if it has not been setup already. if (!m_pAnimator) { if (pToon) m_pAnimator = new CAnimator(pToon); else m_pAnimator = new CAnimator(hWnd, m_lpOffScreen); } }
CStory::CStory(HWND hWindow) /***********************************************************************/ { STRING szString, szFile; FNAME szFileName; HRSRC hResource; HGLOBAL hData; LPSHORT lpShortData; DWORD dwSize; int id; m_hWnd = hWindow; m_nRects = 0; m_hMCIfile = NULL; m_iHighlight = 0; m_pDib = NULL; m_lpWordData = NULL; m_fPlaying = FALSE; m_szStoryFile[0] = '\0'; m_szDibFile[0] = '\0'; m_hHotSpotCursor = LoadCursor(GetWindowInstance(hWindow), MAKEINTRESOURCE(ID_POINTER)); m_fCursorEnabled = TRUE; m_fMappedToPalette = FALSE; GetModuleFileName(GetWindowInstance(hWindow), szFileName, sizeof(szFileName)); StripFile(szFileName); GetWindowText(hWindow, szString, sizeof(szString)); for (int i = 0; i < 2; ++i) { if (GetStringParm(szString, i, ',', szFile)) { if (lstrcmpi(Extension(szFile), ".wav") == 0) { lstrcpy(m_szStoryFile, szFileName); lstrcat(m_szStoryFile, szFile); } else { lstrcpy(m_szDibFile, szFileName); lstrcat(m_szDibFile, szFile); } } else break; } id = GetDlgCtrlID(hWindow)-IDC_STORY; if (id) wsprintf(szString, "story%d", id+1); else lstrcpy(szString, "story"); id = App.GetSceneNo(GetParent(hWindow)); if ( !(hResource = FindResource( App.GetInstance(), MAKEINTRESOURCE(id), szString )) ) return; if ( !(dwSize = SizeofResource( App.GetInstance(), hResource )) ) return; if ( !(hData = LoadResource( App.GetInstance(), hResource )) ) return; if ( !(lpShortData = (LPSHORT)LockResource( hData )) ) { FreeResource( hData ); return; } m_nRects = (int)(dwSize / (sizeof(WORD) * 6)); if (m_nRects) { m_lpWordData = (LPWORD_DATA)AllocX( (m_nRects * sizeof(WORD_DATA)), GMEM_ZEROINIT|GMEM_SHARE ); if (!m_lpWordData) return; for (int i = 0; i < m_nRects; ++i) { m_lpWordData[i].dwFrom = (int)*lpShortData++; m_lpWordData[i].dwTo = (int)*lpShortData++; m_lpWordData[i].rArea.left = (int)*lpShortData++; m_lpWordData[i].rArea.top = (int)*lpShortData++; m_lpWordData[i].rArea.right = (int)*lpShortData++; m_lpWordData[i].rArea.bottom = (int)*lpShortData++; } } UnlockResource( hData ); FreeResource( hData ); }