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

📄 gameintro.cpp

📁 象棋框架
💻 CPP
字号:
// GameIntro.cpp: implementation of the CGameIntro class.
//
//////////////////////////////////////////////////////////////////////

#include "GameIntro.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


CGameIntro::CGameIntro()
{

	//AECHAR b[3];
	//STRTOWSTR("`",b,4);
	m_bCenter = m_bSelLine = false;
	m_nTotalLine = 0;
	m_nVScrollBarWidth = 0;

	m_bBottomBar = m_bTopBar = false;	
	
	m_nFontSpace = FONT_SPACE;	

	m_nBGID = IDB_BG_HELP;
	m_nStrID = IDS_HELP_GAMEINTRO;
	m_nTopTextID = IDS_HELP_INTROTOP;
}

CGameIntro::~CGameIntro()
{

}

void CGameIntro::setFrame(CBrewLogin *f)
{
	frame1 = (CBrewLogin*)f;
	m_pShell = frame1->frame->getCurrentShell();
	m_offsetX = frame1->frame->getScreenOffsetX();
	m_offsetY = frame1->frame->getScreenOffsetY();
	m_pdi = frame1->frame->getDeviceInfo();

	frame2 = NULL;
}

void CGameIntro::setFrame(CBrewHall *f)
{
	frame2 = (CBrewHall*)f;
	m_pShell = frame2->frame->getCurrentShell();
	m_offsetX = frame2->frame->getScreenOffsetX();
	m_offsetY = frame2->frame->getScreenOffsetY();
	m_pdi = frame2->frame->getDeviceInfo();
	
	frame1 = NULL;
}

void CGameIntro::GetInfoRect()		//显示主要信息的区域,不包含辅助内容
{
	AEERect rt;
	GetMainRect(rt);
	if(m_nTotalDisplayLine < m_nTotalLine)
		rt.dx -= m_nVScrollBarWidth;		//减去滚动条所占的区域
	
	SETAEERECT(&m_rtInfo,rt.x,rt.y + m_nNowSize + m_nFontSpace,rt.dx,
		rt.dy - 2*(m_nNowSize + m_nFontSpace));
	
}

void CGameIntro::GetMainRect(AEERect& rt)
{
	CBrewLoginCanvasBase::GetMainRect(rt);
}

void CGameIntro::paint(IDisplay *d, IGraphics *g)
{
	CBrewLoginCanvasBase::paint(d,g);

	DrawExtroInfo();
	AEERect rt;
	int i;
	AECHAR buf[20];
	//AEEFont nfont;
	for(i = 0; i < m_nTotalLine; i++)
	{
		if(GetLineRect(i,rt) != -1)
		{
			int j,k = 0;
			for(j = 0; j < i; j++)
				k += m_aCount[j];
			GetSpecText(k,m_aCount[i],buf,sizeof(buf));
			if(buf[WSTRLEN(buf)-1] == SPLIT)
				buf[WSTRLEN(buf)-1] = 0;	//分隔符不显示
			int32 nw = IDF_ALIGN_MIDDLE;
			if(m_bCenter)
				nw = IDF_ALIGN_CENTER;
			IDISPLAY_DrawText( d, m_nNowFont, buf, -1, 
				rt.x, rt.y,
				&rt, nw | IDF_TEXT_TRANSPARENT |IDF_ALIGN_LEFT);
		}
	}	
	DrawScrollBar();
}

boolean CGameIntro::key(UINT16 code, UINT32 param)
{
	CBrewLoginCanvasBase::key(code,param);
	if(code == AVK_CLR)
		return true;
	
	if(code == AVK_SELECT)
	{
		return true;
	}
	
	return false;
}

void CGameIntro::DrawExtroInfo()
{
	AEERect rt,rtdraw;
	GetMainRect(rt);	
	//IDISPLAY_FillRect(m_pIDisplay,&rt,MAKE_RGB(255,255,255));

	SETAEERECT(&rtdraw,rt.x,rt.y,rt.dx,m_nNowSize + m_nFontSpace);
	IDISPLAY_DrawText(m_pIDisplay,    
		AEE_FONT_BOLD,      
		m_pTopText,          
		-1, 
		0,  
		0,	
		&rtdraw,
		IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT | IDF_ALIGN_MIDDLE );
	
	int n = m_nNowSize + m_nFontSpace;
	SETAEERECT(&rtdraw,rt.x,rt.y+rt.dy - n,rt.dx,n);
	IDISPLAY_DrawText(m_pIDisplay,    
		AEE_FONT_BOLD,      
		GetDispText(IDS_CMN_OKBACK),
		-1, 
		0,  
		0,	
		&rtdraw,
		IDF_ALIGN_CENTER | IDF_TEXT_TRANSPARENT | IDF_ALIGN_MIDDLE );

	rtdraw = m_rtInfo;
	rtdraw.dx = rt.dx;
	//IDISPLAY_DrawRect(m_pIDisplay,&rtdraw,RGB_BLACK,
	//	0,IDF_RECT_FRAME);
}

void CGameIntro::SetDisplayInfo(IDisplay* d)
{
	CBrewLoginCanvasBase::SetDisplayInfo(d);
	

	ISHELL_LoadResString(m_pShell,GAMEVV_RES_FILE,m_nStrID,
		m_pText,sizeof(m_pText));
	ISHELL_LoadResString(m_pShell,GAMEVV_RES_FILE,m_nTopTextID,
		m_pTopText,sizeof(m_pTopText));

	m_nTotalLine = 0;
	int i,j;
	AECHAR buf[20];
	for(i = 0; i < WSTRLEN(m_pText);)
	{
		j = 1;
		int nn = WSTRLEN(m_pText);
		while(GetSpecText(i,j,buf,sizeof(buf)) <= m_rtInfo.dx && i + j - 1 < WSTRLEN(m_pText))
		{
			j++;
			if(m_pText[i+j-2] == SPLIT)
				break;
		}
		j--;
		i += j;		
		m_aCount[m_nTotalLine] = j;
		m_nTotalLine++;
	}
	if(m_nTotalLine > m_nTotalDisplayLine)	//需要滚动条
	{
		m_nVScrollBarWidth = 5;		
		GetInfoRect();
		m_nTotalLine = 0;
		for(i = 0; i < WSTRLEN(m_pText);)
		{
			j = 1;
			int nn = WSTRLEN(m_pText);
			while(GetSpecText(i,j,buf,sizeof(buf)) <= m_rtInfo.dx && i + j - 1 < WSTRLEN(m_pText))
			{
				j++;
				if(m_pText[i+j-2] == SPLIT)
					break;
			}
			j--;
			i += j;		
			m_aCount[m_nTotalLine] = j;
			m_nTotalLine++;
		}
	}

}

int CGameIntro::GetSpecText(int nBegin,int nLen,AECHAR* buf,int nSize)
{
	MEMSET(buf,0,nSize);
	int i ;
	for(i = 0; i < nLen; i++)
	{
		buf[i] = m_pText[nBegin+i];
	}
	int n = IDISPLAY_MeasureText(m_pIDisplay,m_nNowFont,buf);
	return n;
}

⌨️ 快捷键说明

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