⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsestatic.cpp

📁 混乱竞技场的全套代码,客户端资源可以网上搜
💻 CPP
字号:
// GSEStatic.cpp : implementation file
//

#include "stdafx.h"
#include "gstools.h"
#include "GSEStatic.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// GSEStatic

GSEStatic::GSEStatic()
{
	idr_command_auto		= 0;
	idr_command_updatemode	= 0;
	idr_command_step		= 0;
	idr_popup_menu			= 0;
	idr_choose_mode			= 0;	
	idr_command_pause		= 0;
	idr_command_operate		= 0;

	m_isSingleStep			= false;
	m_Pos.x					= 0;
	m_Pos.y					= 0;
	m_RenderStyle			= RS_STRETCH;
	m_dwStepRate			= 100;
	m_isViewportUse			= true;
	m_isWantZBuffer			= true;

	m_isOperating			= true;
	m_enableBackgroundActive	= false;//false;

	m_ptr_bk_texture	= NULL;

}

GSEStatic::~GSEStatic()
{
	SAFE_DELETE(m_ptr_bk_texture);
}


BEGIN_MESSAGE_MAP(GSEStatic, CStatic)
	//{{AFX_MSG_MAP(GSEStatic)
	ON_WM_SIZE()
	ON_WM_SHOWWINDOW()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// GSEStatic message handlers
BOOL GSEStatic::Init()
{
	if(S_OK!=InitEngine(GetSafeHwnd()))
		return false;
	PrepareForRender();
	m_bk_color	= GetBackSurface()->ConvertGDIColor(RGB(132,132,132));
//	CGsEngine::SetActive(false);

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;

	SetSource(&g_source);

	SetBkColor(RGB(132,132,132));
//	pTex	= new CGsTexture(this);
//	pTex->Import("weather\\light1.tex");

	return true;
}



void GSEStatic::OnSize(UINT nType, int cx, int cy) 
{
	CStatic::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(SUCCEEDED(CGsEngine::Resize()))
	{
		PrepareForRender();
	}
	
}

LRESULT GSEStatic::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	MsgProc (message, wParam, lParam);
	int ret = CStatic::WindowProc(message, wParam, lParam);
	return ret;
}

void GSEStatic::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CStatic::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	
}

void GSEStatic::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	RePaint();
	// Do not call CStatic::OnPaint() for painting messages
}






VOID GSEStatic::SetBkTexture(const char *strBkTexture)
{
	SAFE_DELETE(m_ptr_bk_texture);
	if(strBkTexture)
	{
		m_ptr_bk_texture	= new CGsTexture(this);
		m_ptr_bk_texture->SetStreamSource(strBkTexture, FALSE);
		if(FAILED(m_ptr_bk_texture->RestoreObjects()))
		{
			SAFE_DELETE(m_ptr_bk_texture);
		}
	}
}

VOID GSEStatic::SetBkColor(DWORD color)
{
//	m_bk_color	= GetBackSurface()->ConvertGDIColor(color);//D3DRGBA(GetRValue(color)/255.0f,GetGValue(color)/255.0f,GetBValue(color)/255.0f,0.0f );
	m_bk_color	= D3DRGBA(GetRValue(color)/255.0f,GetGValue(color)/255.0f,GetBValue(color)/255.0f,0.0f );
}

HRESULT GSEStatic::OnRender()
{
//	LPDIRECT3DDEVICE7	pd3dDevice	= GetD3dDevice();
//	CGsSurface* pBackSurface	= GetBackSurface();
	
	m_pd3dDevice->Clear(0UL, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,
							   m_bk_color, 
							   1.0f, 0L );
	if(m_ptr_bk_texture)
	{
		float a = (float)GetRenderWidth()/m_ptr_bk_texture->GetWidth();
		float b = (float)GetRenderHeight()/m_ptr_bk_texture->GetHeight();
		PreparePaint();
		SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTFN_POINT );
		SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTFN_POINT );
		m_apPaintVertex[0].sx	= 0;
		m_apPaintVertex[0].sy	= 0;
		m_apPaintVertex[0].sz	= 1.0F;
		m_apPaintVertex[1].sx	= GetRenderWidth();
		m_apPaintVertex[1].sy	= 0;
		m_apPaintVertex[1].sz	= 1.0F;
		m_apPaintVertex[2].sx	= 0;
		m_apPaintVertex[2].sy	= GetRenderHeight();
		m_apPaintVertex[2].sz	= 1.0F;
		m_apPaintVertex[3].sx	= GetRenderWidth();
		m_apPaintVertex[3].sy	= GetRenderHeight();
		m_apPaintVertex[3].sz	= 1.0F;
		m_apPaintVertex[0].color = m_apPaintVertex[1].color = m_apPaintVertex[2].color = m_apPaintVertex[3].color = D3DRGBA(0.5,0.5,0.5,1.0);
		m_apPaintVertex[0].tu	= 0.0f;
		m_apPaintVertex[0].tv	= 0.0f;
		m_apPaintVertex[1].tu	= a;
		m_apPaintVertex[1].tv	= 0.0f;
		m_apPaintVertex[2].tu	= 0.0f;
		m_apPaintVertex[2].tv	= b;
		m_apPaintVertex[3].tu	= a;
		m_apPaintVertex[3].tv	= b;
		m_pd3dDevice->SetTexture(0, m_ptr_bk_texture->GetDDrawSurface());
		m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 
										  D3DFVF_TLVERTEX,
										  (LPVOID)m_apPaintVertex,
										  4,
										  0 );
		
		m_apPaintVertex[0].tu	= 0.0f;
		m_apPaintVertex[0].tv	= 0.0f;
		m_apPaintVertex[1].tu	= 1.0f;
		m_apPaintVertex[1].tv	= 0.0f;
		m_apPaintVertex[2].tu	= 0.0f;
		m_apPaintVertex[2].tv	= 1.0f;
		m_apPaintVertex[3].tu	= 1.0f;
		m_apPaintVertex[3].tv	= 1.0f;
	}

	CGsEngine::OnRender();
	

	return S_OK;
}
HRESULT GSEStatic::OnDraw(CGsSurface *pSurface)
{
//	pSurface->DrawText(NULL, g_strInfo, 20, 30, RGB(255,255,255), RGB(1,1,1));
	UpdateBounds();
	return CGsEngine::OnDraw(pSurface);
}

HRESULT GSEStatic::RestoreSource()
{

	if(m_ptr_bk_texture)
	{
		m_ptr_bk_texture->RestoreObjects();
	}

	return CGsEngine::RestoreSource();
}

HRESULT GSEStatic::ReleaseSource()
{
	if(m_ptr_bk_texture)
	{
		m_ptr_bk_texture->ReleaseObjects();
	}

	return CGsEngine::ReleaseSource();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -