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

📄 kscutil.cpp

📁 这是一个用BREW和VC++开发的暴力摩托游戏,与大家一同分享.
💻 CPP
字号:
// KSCUtil.cpp: implementation of the KSCUtil class.
//
//////////////////////////////////////////////////////////////////////

#include "KSCUtil.h"

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

KSCUtil::KSCUtil(IDisplay*	IDisplay)
{
	m_pIDisplay = IDisplay;
}

KSCUtil::~KSCUtil()
{
	m_pIDisplay = NULL;
}

// KSC5601甫 AECHAR内靛肺 函券
void KSCUtil::KSC5601ToAECHAR(const char *src, AECHAR *dest)
{
	int			i, j;

	for( i = 0, j = 0 ; src[i] != NULL ; i++ )
	{
		if (((uint8)src[i]) & 0x80)
		{
			MEMCPY( &dest[j], &src[i], 2 );
			i++;
		}
		else
			dest[j] = (AECHAR)src[i];
		j++;
	}
	dest[j] = 0;
}

// AECHAR甫 KSC5601内靛肺 函券
void KSCUtil::AECHARToKSC5601(const AECHAR *src, char *dest)
{
	int			i, j;

	for( i = 0, j = 0 ; src[i] != NULL ; i++ )
	{
		if( src[i] > 128 )
		{
			MEMCPY( &dest[j], &src[i], 2 );
			j++;
		}
		else
			dest[j] = (char)src[i];
		j++;
	}
	dest[j] = 0;
}

// 变 咆胶飘甫 width父怒狼 啊肺侨伎俊 嘎苗 嘛阑锭
// 醚 割临捞 登绰啊甫 府畔
int KSCUtil::GetSFSLines(AECHAR *wbuf, int width)
{
	int			pnFit = 0, max;
	int			pos = 0, i, w;
	int			line = 0;
	boolean		bcheck = FALSE;
	int			len = WSTRLEN( wbuf );

	// '|' 啊 唱鸥唱搁 秦寸临篮 啊款单 沥纺
	if( wbuf[pos] == '|' )
	{
		pos++;
	}

	while( pos < len )
	{
		w = MeasureText( &wbuf[pos], -1, width, &pnFit );
		max = pos + pnFit;
		bcheck = FALSE;
		for( i = pos ; i < max ; i++ )
		{
			// ';' 捞 唱鸥唱搁 俺青.
			if( wbuf[i] == ';' )
			{
				line++;
				if( wbuf[i+1] == '|' )
				{
					pos += (i - pos +2);
				}
				else
					pos += (i - pos +1);
				bcheck = TRUE;
				break;
			}
		}
		if( !bcheck )
		{
			line++;
			pos += pnFit;

            // Appended by MYLOVE (040325)
            // 磊悼利栏肺 俺青等 促澜俊 俺青巩磊(';')啊 乐栏搁 Skip
            if (wbuf[pos] == ';') pos++;
		}
	}

	return line;
}

// IDISPLAY_MeasureTextEx甫 措眉秦辑 荤侩窍绰 窃荐肺 盔夯 窃荐狼 府畔蔼捞 0老锭 
// 盔夯 窃荐甫 俊鼓饭捞记茄 搬苞甫 府畔茄促.
int KSCUtil::MeasureText( AECHAR *str, int nChars, int nMaxWidth, int *pnFits)
{
	int         i, width;
    int         charSize;

    width = IDISPLAY_MeasureTextEx( m_pIDisplay, AEE_FONT_NORMAL, str, nChars, nMaxWidth, pnFits );
    if (width == 0 || *pnFits == 0)
    {
        i = WSTRLEN(str);
        if (nChars < 0) nChars = i;						// nChars < 0 捞搁 辨捞甫 磊悼栏肺 拌魂
        if (nMaxWidth <= 0)
        {
            nMaxWidth = 255;
            if (pnFits != NULL) *pnFits = i;			// nMaxWidth <= 0 捞搁 *pnFits = 巩磊凯狼 傈眉 辨捞
        }

        width = 0;
        for (i = 0; i < nChars; i++)
        {
            if (str[i] & 0x80)
            {
                charSize = 12;
            }
            else
            {
                if (str[i] == NULL) break;
                charSize = 6;
            }
            width += charSize;
            if (width >= nMaxWidth)
            {
                width -= charSize;
                if (pnFits != NULL) *pnFits = i;
                break;
            }
        }
        if (i >= nChars && pnFits != NULL) *pnFits = i;
    }

    return width;
}

void KSCUtil::DrawSFS(AECHAR *wbuf, int npage, int sline, int nline, int width, int x, int y, RGBVAL color)
{
	int			pnFit, max;
	int			pos = 0, i, w;
	int			line = 0, pline = (npage - 1)*nline + 1;
	int			line_start =0;
	boolean		bcheck = FALSE, bcenter = FALSE;
	int			len = WSTRLEN( wbuf );
	RGBVAL		oldcolor = IDISPLAY_SetColor( m_pIDisplay, CLR_USER_TEXT, color );

	if( wbuf[pos] == '|' ) {
		bcenter = TRUE;
		pos++;
	}

	while( pos < len && line < (pline+nline-1) ) {	
        w = IDISPLAY_MeasureTextEx( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], -1, width, &pnFit );
		max = pos + pnFit;
		bcheck = FALSE;
		for( i = pos ; i < max ; i++ ) {
			if( wbuf[i] == ';' ) {
				if(line_start <sline ) line_start++;
				else
				{
					// 俺青贸府
					line++;
					if( line >= pline ) {
						if( (i-pos) > 0 ) 
						{							
							if( bcenter )
							{
								w = IDISPLAY_MeasureTextEx( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], i - pos, width, &pnFit );
								IDISPLAY_DrawText( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], i - pos, x + (width - w)/2, y + (line-pline) * 15, 0, IDF_TEXT_TRANSPARENT );
							}
							else IDISPLAY_DrawText( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], i - pos, x, y + (line-pline) * 15, 0, IDF_TEXT_TRANSPARENT );
						}
					}
				}
				bcenter = FALSE;

				if( wbuf[i+1] == '|' ) {
					// 啊款单 沥纺
					bcenter = TRUE;
					pos += (i - pos + 2);
				} else
					pos += (i - pos + 1);
				bcheck = TRUE;
				break;
			}
		}

		if( !bcheck ) {
			if(line_start <sline ) line_start++;
			else
			{
				line++;
				if( line >= pline ) {
					if( bcenter ) IDISPLAY_DrawText( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], pnFit, x + (width - w)/2, y + (line-pline) * 15, 0, IDF_TEXT_TRANSPARENT );
					else          IDISPLAY_DrawText( m_pIDisplay, AEE_FONT_NORMAL, &wbuf[pos], pnFit, x, y + (line-pline) * 15, 0, IDF_TEXT_TRANSPARENT );
				}
				}
			bcenter = FALSE;
			pos += pnFit;

            // Appended by MYLOVE (040325)
            // 磊悼利栏肺 俺青等 促澜俊 俺青巩磊(';')啊 乐栏搁 Skip
            if (wbuf[pos] == ';') pos++;
		}
	}

	IDISPLAY_SetColor( m_pIDisplay, CLR_USER_TEXT, oldcolor );
}

void KSCUtil::DrawImage(CMImage* pImage, int posX, int posY)
{
	//drawImagePart(pImg, nX, nY);
	IDISPLAY_BitBlt(m_pIDisplay,
		posX, posY,
		pImage->getWidth(), pImage->getHeight(),
		pImage->getBmp(),
		0, 0,
		AEE_RO_MASK);
}
/*
void DrawImage(CMImage* pImage, int posX, int posY, int anchor )
{
	if (pImage==NULL) 
		return;
	AEEPoint pt;	
	AEEImageInfo info;

	IIMAGE_GetInfo( pImage, &info );

	pt.x = posX;
	pt.y = posY;
	AdjustCoordsByAnchor( &pt, info.cx, info.cy, anchor );

#ifdef BREW20
	IIMAGE_SetParm(pImage,IPARM_ROP,AEE_RO_TRANSPARENT,0);
	IIMAGE_Draw(pImage, pt.x, pt.y);
#else
	IIMAGE_SetParm(pImage,IPARM_ROP,AEE_RO_TRANSPARENT,0);
	DrawImage(pImage, pt.x, pt.y);
#endif
}
*/

⌨️ 快捷键说明

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