Exemple #1
0
//************************************************************************
PTOON CGBScene::GetToon()
//************************************************************************
{
	HWND hToon = FindClassDescendent(m_hWnd, "toon");
	if (hToon)
		return(::GetToon(hToon));
	else
		return(NULL);
}
Exemple #2
0
// Process the reply messages for ICSS asynchronous requests
//******************************************************************************
long ProcessICSSReplyMsg(HWND hWnd, UINT wFuncId, long lData)
//******************************************************************************
{
	ICSS_RETURN_WORDS FAR *pWords;
	ICSS_PARMTYPE parm_val;

	long lRetCode = ICSS_SUCCESS;
	switch (wFuncId)
	{
		case REPLY_START_CONVERSATION:
		{
			/******************************************************************************/
			/* This section processes the asynchronous portion of the StartConversation	  */
			/* call, including error processing and initiating the context loading.		  */
			/******************************************************************************/
			if (lRetCode = lData)
			{
				VoiceRecoClose();
				Print( "Failed trying to startup voice recognition. (code %ld)", lRetCode );
				break;
			}

			lRetCode = ICSSLoadContext (&lContextHandle, "jungle.ctx", ICSS_DEFAULT_FLOAT,
						ICSS_DEFAULT_FLOAT, ICSS_DEFAULT_FLOAT, ICSS_DEFAULT_FLOAT);
			if (lRetCode != ICSS_SUCCESS)
			{
				VoiceRecoClose();
				Print( "Failed trying to load the voice context. (code %ld)", lRetCode );
				break;
			}

			// Set timeout for speech to 5 seconds
			parm_val.ICSS_FLOATParameterData = (float)5.0;
			ICSSSetValue(ICSS_CFLT_UTT_MAX_SIL_DURATION,parm_val);

			// eliminate server, mci and rcp icons
			parm_val.ICSS_INTParameterData = 0L;
			ICSSSetValue(ICSS_CINT_VERBOSE_LEVEL,parm_val);
			break;
		}

		case REPLY_GET_SPOKEN_WORDS:
		{
			/******************************************************************************/
			/*	This section processes the asynchronous results from the GetSpokenWords	  */
			/*	call, including error checking, display of recognized text and the		  */
			/*	automatic start of the ICSS and application termination.				  */
			/******************************************************************************/
			if ( !bInit )
				break;
		#ifdef WIN32
			ICSS_RETURN_WORDS retWords;
			pWords = &retWords;
			lRetCode = ICSSDecodeReturnedWords((int)lData, &retWords);
		#else
			pWords = (ICSS_RETURN_WORDS FAR *)GlobalLock((HANDLE)lData);
		#endif
			if ( !pWords || pWords->return_code != ICSS_SUCCESS)
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 99, SendMessage); // send an invalid responce
			}
			else
			if ( !pWords->spoken_words )
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 99, SendMessage); // send an invalid responce
			}
			else
			if (!lstrcmp((LPSTR)pWords->spoken_words, "AWOWOW"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 0, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "CHAKEECHA"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 1, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "CHEKACHEE"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 2, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "JAKEETA"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 3, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "JATA"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 4, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "KACHEEKEE"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 5, SendMessage);
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "KAKEE"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 6, SendMessage); // treat the same as "kakeeta"
			}
			else 
			if (!lstrcmp((LPSTR)pWords->spoken_words, "KAKEETA"))
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 6, SendMessage); // treat the same as "kakee"
			}
			else 
			{
				FORWARD_WM_COMMAND (FindClassDescendent(hWnd, "scene"),
					IDC_VRECO_MSG, hWnd, 99, SendMessage); // send an invalid responce
			}
		#ifndef WIN32
			GlobalUnlock((HANDLE)lData);
			GlobalFree((HANDLE)lData);
		#endif
			break;
		}

		default:
			break;
	}
	return lRetCode;
}
Exemple #3
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	PTOON pToon = NULL;
	PDIB pdibSrc, pdibDst;
	LPOFFSCREEN lpOffScreen = NULL;

	if (IsRectEmpty(lpRect))
		return;
	PSTORY pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	// Draw the Bitmap
	rSrcArea = *lpRect;
	rDstArea = *lpRect;

	LPSCENE lpScene = CScene::GetScene(GetParent(hWindow));
	if (lpScene)
		lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
	 	if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
	}
	else
	{
		// see if there is a toon control
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		pdibSrc = pToon->GetStageDib();
		MapWindowPoints( hWindow, GetParent(hToon), (LPPOINT)&rDstArea, 2 );
 	}

	// create a dib to draw into
	pdibDst = new CDib();
	if (!pdibDst)
		return;
	if (!pdibDst->Create(pdibSrc->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pdibDst;
		return;
	}
	pdibDst->CopyColorTable(pdibSrc);
	
	// copy our color table into the dest dib
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	// draw in background
	pdibSrc->DibBlt( pdibDst,
					0, 0,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	rDstArea.left, rDstArea.top,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	NO /*bTransparent*/ );

	// now draw in foreground
	RGBTRIPLE rgb;
	LPRGBTRIPLE lpRGB = NULL;
	if (dwStyle & BS_MASK)
	{
		STRING szColor;
		GetWindowText(hWindow, szColor, sizeof(szColor));
		AsciiRGB( szColor, &rgb );
		if (fHighlight)
		{
			// this relies on the fact that AsciiRGB replaces commas
			// with NULL terminators
			LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
			lp += lstrlen(lp) + 1; // passed green
			lp += lstrlen(lp) + 1; // passed blue to higlight color
			AsciiRGB(lp, &rgb);
			rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
		}
		else
			rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
		lpRGB = &rgb;
	}
	pStory->m_pDib->DibBlt( pdibDst,
				0, 0,
				rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				YES /*bTransparent*/, lpRGB, App.m_lpLut );

	pdibDst->DCBlt( hDC,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
			 	0, 0,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);

	delete pdibDst;
}
Exemple #4
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	POINT ptDst;
	PDIB pdibSrc, pdibDst, pDib;
	LPOFFSCREEN lpOffScreen;
	PTOON pToon;
	LPSCENE lpScene;
	PSTORY pStory;
	RGBQUAD rgbQuad[256];
	BITMAPINFOHEADER bmi;
	LPTR lp;
	HDC hWinGDC;
	HPALETTE hWinGPal = NULL, hDisplayPal = NULL, hOldPal;

	if (IsRectEmpty(lpRect))
		return;
	pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	lpScene = CScene::GetScene(GetParent(hWindow));
	if (!lpScene)
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;
	bSelected = GetWindowWord(hWindow, GWW_STATE );
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
 		if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		if ( !(pdibDst = lpOffScreen->GetWritableDIB()) )
			return;
		hWinGDC = lpOffScreen->GetDC();
		hWinGPal = hDisplayPal = GetApp()->m_hPal;
	}
	else
	{
		// fix
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		MapWindowPoints( hWindow, pToon->GetWindow(), (LPPOINT)&rDstArea, 2 );
		pdibSrc = pToon->GetStageDib();
		lp = ToonGetDIBPointer(pToon->GetToonHandle(), &bmi);
		ToonGetColors(pToon->GetToonHandle(), 0, 256, rgbQuad);
		bmi.biClrUsed = 256;
		pdibDst = new CDib(&bmi, rgbQuad, lp);
		if (!pdibDst)
			return;
		hWinGDC = ToonDC(pToon->GetToonHandle());
		// to make sure we don't change the system palette
		hDisplayPal = CopySystemPalette();
		// to match WinG dib
		hWinGPal = CreateCustomPalette(rgbQuad, 256);
	}

	if (!pStory->m_fMappedToPalette && ((dwStyle & BS_MASK) == 0))
	{
		pStory->m_pDib->MapToPalette(hWinGPal);
		pStory->m_fMappedToPalette = TRUE;
	}


	// Copy source dib so we can twiddle its bits
	pDib = new CDib();
	if (!pDib)
	{
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	if (!pDib->Create(pStory->m_pDib->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pDib;
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	pDib->CopyColorTable(pStory->m_pDib);
	// draw in source bitmap
	pStory->m_pDib->DibBlt( pDib,
					0, 0,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	rSrcArea.left, rSrcArea.top,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	NO /*bTransparent*/ );
	
	if ( pdibSrc->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8)
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
	}
	else
	{
		pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	NO /*bTransparent*/ );
	}

	if ( pDib->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8 )
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pDib->DCBlt( hWinGDC,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					rSrcArea.left, rSrcArea.top,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
	}
	else
	{
		RGBTRIPLE rgb;
		LPRGBTRIPLE lpRGB = NULL;
		if (dwStyle & BS_MASK)
		{
			STRING szColor;
			GetWindowText(hWindow, szColor, sizeof(szColor));
			AsciiRGB( szColor, &rgb );
			if (fHighlight)
			{
				// this relies on the fact that AsciiRGB replaces commas
				// with NULL terminators
				LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
				lp += lstrlen(lp) + 1; // passed green
				lp += lstrlen(lp) + 1; // passed blue to higlight color
				AsciiRGB(lp, &rgb);
				rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
			}
			else
				rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
			lpRGB = &rgb;
		}
		else
		{
			BYTE bTrans = *pStory->m_pDib->GetXY(0, 0);
			LPTR lpColor = pStory->m_pDib->GetXY(1, 0);
			LPTR lpHighlight = pStory->m_pDib->GetXY(2, 0); 
			BYTE bColor = *lpColor;
			BYTE bHighlight = *lpHighlight;
			// if highlight color is the transparent color then
			// we are hiding and showing highlighted area
			// if not, then we are changing the color of highlighted area
			if (bHighlight == bTrans)
			{
				// we need to strip off highlight info if we are not
				// highlighted
				if (!fHighlight && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp != bColor)
							*hp = bTrans;
						++hp;
						--dwSize;
					}
				}
			}
			else
			{
				// we need to change the color if we are highlighted
				if (fHighlight && (bColor != bHighlight) && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp == bColor)
							*hp = bHighlight;
						++hp;
						--dwSize;
					}
				}
			}
		}
		pDib->DibBlt( pdibDst,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					0, 0,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
					YES/*bTransparent*/, lpRGB, NULL, hWinGPal );
	}
	delete pDib;

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (lpOffScreen)
	{
		lpOffScreen->DrawRect( hDC, &rDstArea, &ptDst );
	}
	else
	{
		//if (hDisplayPal)
		//{
		//	hOldPal = SelectPalette(hDC, hDisplayPal, FALSE);
		//	RealizePalette(hDC);
		//}
		//pdibDst->DCBlt( hDC,
		//	ptDst.x, ptDst.y,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
		//	rDstArea.left, rDstArea.top,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		WinGStretchBlt( hDC,
			ptDst.x, ptDst.y,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
			hWinGDC,
			rDstArea.left, rDstArea.top,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		//if (hDisplayPal)
	    //{
		//	SelectPalette(hDC, hOldPal, TRUE);
	   	//	DeleteObject(hDisplayPal);
		//}
		if (hWinGPal)
			DeleteObject(hWinGPal);
	}
}