Example #1
0
LRESULT LGameWindow::MessageProc(IN UINT message, IN WPARAM wParam, IN LPARAM lParam)
{
	switch (message)
	{	
	case WM_DESTROY:
		PostQuitMessage (0);
		return 0;
	case WM_SIZE:
		{
			// 窗口大小改变重新初始化后备缓冲区
			int width = LOWORD(lParam);
			int height = HIWORD(lParam);
			this->SetSize(width, height);
			HWND hWnd = this->GetWndHandle();
			m_backDC.Init(hWnd, width, height);
		}
		break;
	case WM_PAINT:
		this->PaintGame();
		break;
	case WM_KEYUP:
		this->KeyUpMessage(wParam, lParam);
		break;
	default:
		break;
	}

	return DefWindowProc(GetWndHandle(), message, wParam, lParam);
}
Example #2
0
void CBigMap::DrawBigMap()
{
	CFRect rtWnd = CFRect( 0, 0, (float)GetWndWidth(), (float)GetWndHeight() );

	CColor uColor = CColor::White;
	CVector2f vStart( (float)GetWndHandle()->m_xScreen, (float)GetWndHandle()->m_yScreen );
	CVector2f rtScreen[4] = { vStart
		, vStart + CVector2f((float)GetWndHandle()->m_Width,0.0f)
		, vStart + CVector2f(0.0f,(float)GetWndHandle()->m_Height)
		, vStart + CVector2f((float)GetWndHandle()->m_Width,(float)GetWndHandle()->m_Height)};

	float Zoom = GetRootWnd()->GetZoomSize();

	IMAGE& image = GetWndHandle()->m_Enable.GetImage(0);
	
	CFRect rtImage((float)image.posWnd.x, (float)image.posWnd.y, image.posWnd.x + abs(image.rtTexture.Width()), image.posWnd.y + abs(image.rtTexture.Height()));
	rtImage.top		*= Zoom;
	rtImage.left	*= Zoom;
	rtImage.bottom	*= Zoom;
	rtImage.right	*= Zoom;
	CFRect rtDraw = rtWnd.Intersection(rtImage).Offset(0.0f,0.0f);
	CFRect rtText(
		image.rtTexture.left,
		image.rtTexture.top,
		( rtImage.right  - rtImage.left )*image.rtTexture.Width() /rtImage.Width()  + image.rtTexture.left,
		( rtImage.bottom -  rtImage.top )*image.rtTexture.Height()/rtImage.Height() + image.rtTexture.top);

	if(m_bOpen&&!m_bClose)
		DrawRect(m_MapTextureOpen, rtDraw, uColor, &rtText,false);
	else
		DrawRect( rtScreen, uColor,m_pAlphaTexture,m_MapTextureOpen,m_MapTextureClose/*,&rtText,m_BackTexUV*/, RS_GUI_BIGMAP, GetWndHandle()->m_fZ );	
}
Example #3
0
void LGameWindow::Exe()
{
	this->InitGame();

	bool bDone = false;
	MSG msg;

	LFrameTimer frameTimer(60);
	frameTimer.Start();

	while(!bDone)
	{
		while(PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) 
		{
			if( msg.message == WM_QUIT ) 
			{
				bDone = true;
			} 
			else 
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}

		if (frameTimer.ReadyForNextFrameEx() || m_bFastGenerate)
		{
			this->RunGame();

			if (m_bFastGenerate && (m_frameCount != 0))
				continue;

			InvalidateRect(GetWndHandle(), NULL, TRUE);
			UpdateWindow(GetWndHandle());
		}
		else
		{
			Sleep(0);
		}

	}
}
Example #4
0
void SQRWndOffSet::DrawText( const wstring& text, float x, float y, CColor color, CColor bkColor, bool multiline, CFRect* rect )
{
	const WndHandle* handle = GetWndHandle();
	if ( !handle->m_WndFont || text.empty())
		return;

	// 滚动控件忽略x方向文字的对齐方式
	x = 0;

	CFRect rtWnd = rect ? *rect : CFRect( 0, 0, GetWndWidth(), GetWndHeight() );
	if ( GetStyle()&WS_CUTBYPARENT )
	{
		WndToScreen( rtWnd );
		x += rtWnd.left;
		y += rtWnd.top;
		CFRect rtParent;
		GetParent()->GetWndRect( rtParent );
		rtWnd = rtWnd.Intersection(rtParent);
		x -= rtWnd.left;
		y -= rtWnd.top;
		rect = &rtWnd;
		ScreenToWnd( rtWnd );
	}
	if ( m_pCutWnd )
	{
		CFRect rtCutWnd;
		m_pCutWnd->GetCutAreaRect(rtCutWnd);
		ScreenToWnd( rtCutWnd );
		rtWnd = rtWnd.Intersection(rtCutWnd);
	}

	CColor gradual = GetFontGradualColor();
	color.A = uint8(color.A * m_hWnd->m_fTransparent);
	bkColor.A = uint8(bkColor.A * m_hWnd->m_fTransparent);
	gradual.A = uint8(gradual.A * m_hWnd->m_fTransparent);

	FontEffect::Mask mask = GetFontEffectMask();
	if (multiline)
		mask |= FontEffect::Multiline;

	WndToScreen( rtWnd );

	if ( (WS_MULLINETEXT&GetStyle()) != WS_MULLINETEXT )
	{
		float Height = GetFontSize()*m_hWnd->m_pGUI->GetZoomSize();
		if ( GetStyle() & WS_TEXTYC )
			y = (m_hWnd->m_Height - Height)/2;
	}

#ifdef UI_HIDE_MODE
	if (handle->m_pGUI->GetHidenMode() && !IsModleState() )
	{
		return;
	}
#endif

	handle->m_pGUI->DrawText(handle->m_WndFont, handle->m_FontSize,
	                         text, color, bkColor, gradual,
	                         rtWnd, x, y, handle->m_fZ,
	                         mask, mStepResult);
}