📄 mapinfo.cpp
字号:
{
// Search the last word
for ( int j = i; j >= 0; j-- )
{
if ( Static[j] == '~' )
{
i -= i - j;
break;
}
}
}
//----------End the english version's process(jump line)----------//
if ( nSingle % 2 == 0 )
{
nSingle = 0;
nLineNum = 0;
nDescLine++;
nCharIndex[nDescLine] = i + 1;
}
else
{
nDescLine++;
nCharIndex[nDescLine] = i - ( nLineNum - nMaxLen );
i -= nLineNum - 2;
nSingle = 0;
nLineNum = 0;
}
}
}
if ( nLineNum < nMaxLen && nLineNum != 0 )
{
nDescLine++ ;
nCharIndex[nDescLine] = i;
}
char strTemp[32]="";
int nOffset = 0;
for (i = 0; i < nDescLine; i++ )
{
strncpy ( strTemp, Static + nCharIndex[i], nCharIndex[i + 1] - nCharIndex[i] );
strTemp[nCharIndex[i + 1] - nCharIndex[i]] = '\0';
if (bTline)
{
CMyPos posStr = {_REGIONDES_POSX, _REGIONDES_POSY};
CMyBitmap::ShowTString (posStr.x - nOffset,
posStr.y ,
m_dwDesColor | (dwAlpha << 24),
strTemp,(char*)_REGION_FONT,nFontSize,true) ;
nOffset += 26;
}
else
{
CMyPos posStr = {_SCR_WIDTH/2 - nFontSize/2 * strlen(strTemp)/2, _REGIONNAME_POSY + 50};
CMyBitmap::ShowString (posStr.x,
posStr.y + nOffset,
m_dwDesColor | (dwAlpha << 24),
strTemp,(char*)_REGION_FONT,nFontSize,true) ;
nOffset += 26;
}
}
}
return FALSE;
}
BOOL CGameMap::ShowRegionNameRoll()
{
const DWORD dwShowDelay = 1000;
const DWORD dwStayTime = 2000;
DWORD dwAlpha = 0xfd;
const int nFontSize = 48;
CMyPos posStrE = {_SCR_WIDTH/2 - nFontSize/2 * strlen(m_szRegionName)/2, _REGIONNAME_POSY};
CMyPos posStrS = {_SCR_WIDTH/2 + nFontSize/2 * strlen(m_szRegionName)/2, _REGIONNAME_POSY};
DWORD dwTimePass = ::TimeGet() - m_dwRegionEffectBegin;
int nStrlen = strlen(m_szRegionName);
int MoveX = posStrS.x - dwTimePass/45;
if (MoveX <= posStrE.x)
{
MoveX = posStrE.x;
}
CMyBitmap::ShowString(MoveX, posStrE.y, m_dwNameColor | (dwAlpha << 24),m_szRegionName , (char*)_REGION_FONT, nFontSize, true);
return FALSE;
}
BOOL CGameMap::ShowRegionDesRoll(BOOL bTline)
{
const DWORD dwShowDelay = 1000;
const DWORD dwStayTime = 2000;
DWORD dwAlpha = 0xfd;
DWORD dwTimePass = ::TimeGet() - m_dwRegionEffectBegin;
char Static[128] ;
strcpy(Static,m_szRegionDes);
if(!Static || strlen(Static)==0)
return TRUE;
int nMaxLen = 32;
if (bTline)
nMaxLen = 32;
else
nMaxLen = 20;
int nDescLine = 0 ;
int nCharIndex[10];
nCharIndex[0] = 0;
int nSingle = 0;
int nLineNum = 0;
for ( int i = 0; i < strlen ( Static); i++ )
{
if ( CMyBitmap::IsDBCSLeadByte( Static, i ) )
{
nLineNum += 2;
i++;
}
else
{
nSingle++;
nLineNum++;
}
if ( nLineNum >= nMaxLen )
{
//----------Begin the english version's process(jump line)----------//
if ( strcmp( g_objGameDataSet.GetVersionInfo(), "English" ) == 0 )
{
// Search the last word
for ( int j = i; j >= 0; j-- )
{
if ( Static[j] == '~' )
{
i -= i - j;
break;
}
}
}
//----------End the english version's process(jump line)----------//
if ( nSingle % 2 == 0 )
{
nSingle = 0;
nLineNum = 0;
nDescLine++;
nCharIndex[nDescLine] = i + 1;
}
else
{
nDescLine++;
nCharIndex[nDescLine] = i - ( nLineNum - nMaxLen );
i -= nLineNum - 2;
nSingle = 0;
nLineNum = 0;
}
}
}
if ( nLineNum < nMaxLen && nLineNum != 0 )
{
nDescLine++ ;
nCharIndex[nDescLine] = i;
}
char strTemp[64] ="";
int nOffset = 0;
const int nFontSize = 24;
for (i = 0; i < nDescLine; i++ )
{
strncpy ( strTemp, Static + nCharIndex[i], nCharIndex[i + 1] - nCharIndex[i] );
strTemp[nCharIndex[i + 1] - nCharIndex[i]] = '\0';
if (bTline)
{
CMyPos posStrS = {_REGIONDES_POSX, _REGIONDES_POSY + 400};
CMyPos posStrE = {_REGIONDES_POSX, _REGIONDES_POSY};
int nStrlen = strlen(strTemp);
int MoveY = posStrS.y - dwTimePass/45;
if (MoveY <= posStrE.y)
{
MoveY = posStrE.y;
return TRUE;
}
CMyBitmap::ShowTString(posStrE.x + nOffset, MoveY, m_dwDesColor | (dwAlpha << 24),strTemp , (char*)_REGION_FONT, nFontSize, true);
nOffset +=26;
}
else
{
CMyPos posStrE= {_SCR_WIDTH/2 - nFontSize/2 * strlen(strTemp)/2, _REGIONNAME_POSY + 50};
CMyPos posStrS= {_SCR_WIDTH/2 + nFontSize/2 * strlen(strTemp)/2, _REGIONNAME_POSY + 50};
int nStrlen = strlen(strTemp);
int MoveX = posStrS.x - dwTimePass/33;
if (MoveX <= posStrE.x)
{
MoveX = posStrE.x;
return TRUE;
}
CMyBitmap::ShowString(MoveX , posStrS.y + nOffset, m_dwDesColor | (dwAlpha << 24),strTemp , (char*)_REGION_FONT, nFontSize, true);
nOffset +=26;
}
}
return FALSE;
}
BOOL CGameMap::ShowRegionNameWindow()
{
const DWORD dwShowDelay = 1000;
const DWORD dwStayTime = 2000;
DWORD dwAlpha = 0xfd;
DWORD dwTimePass = ::TimeGet() - m_dwRegionEffectBegin;
if(dwTimePass > dwShowDelay*2+dwStayTime)
{
return TRUE;
}
char szRegionDes1[128] = "";
char szRegionDes2[128] = "";
char ss[2] ="";
int nIndex = 0;
for(int i=0;i<strlen(m_szRegionName);i++)
{
ss[0] = m_szRegionName[i];
ss[1] = m_szRegionName[i+1];
if ( ( BYTE )ss[0] > 0x80 && ( BYTE )ss[0] < 0xfe)
{
i++;
nIndex++;
if (nIndex%2 == 0)
{
strncat(szRegionDes2,ss,2);
strcat(szRegionDes1," \0");
}
else
{
strncat(szRegionDes1,ss,2);
strcat(szRegionDes2," \0");
}
}
else
{
nIndex++;
if (nIndex%2 == 0)
{
strncat(szRegionDes2,ss,1);
strcat(szRegionDes1," \0");
}
else
{
strncat(szRegionDes1,ss,1);
strcat(szRegionDes2," \0");
}
}
}
const int nFontSize = 48;
CMyPos posStr = {_SCR_WIDTH/2 - nFontSize/2 * strlen(m_szRegionName)/2, _REGIONNAME_POSY};
if (dwTimePass < dwShowDelay)
CMyBitmap::ShowString(posStr.x, posStr.y, m_dwNameColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
else if (dwTimePass > dwShowDelay+dwStayTime)
{
CMyBitmap::ShowString(posStr.x, posStr.y, m_dwNameColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
}
else
{
CMyBitmap::ShowString(posStr.x, posStr.y, m_dwNameColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
CMyBitmap::ShowString(posStr.x, posStr.y, m_dwNameColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
}
return FALSE;
}
BOOL CGameMap::ShowRegionDesWindow(BOOL bTline)
{
const DWORD dwShowDelay = 1000;
const DWORD dwStayTime = 2000;
DWORD dwAlpha = 0xfd;
DWORD dwTimePass = ::TimeGet() - m_dwRegionEffectBegin;
if(dwTimePass > dwShowDelay*2+dwStayTime)
{
return TRUE;
}
char Static[128] ;
strcpy(Static,m_szRegionDes);
if(!Static || strlen(Static)==0)
return TRUE;
int nMaxLen = 32;
if (bTline)
nMaxLen = 32;
else
nMaxLen = 20;
int nDescLine = 0 ;
int nCharIndex[10];
nCharIndex[0] = 0;
int nSingle = 0;
int nLineNum = 0;
for ( int i = 0; i < strlen ( Static); i++ )
{
if ( CMyBitmap::IsDBCSLeadByte( Static, i ) )
{
nLineNum += 2;
i++;
}
else
{
nSingle++;
nLineNum++;
}
if ( nLineNum >= nMaxLen )
{
//----------Begin the english version's process(jump line)----------//
if ( strcmp( g_objGameDataSet.GetVersionInfo(), "English" ) == 0 )
{
// Search the last word
for ( int j = i; j >= 0; j-- )
{
if ( Static[j] == '~' )
{
i -= i - j;
break;
}
}
}
//----------End the english version's process(jump line)----------//
if ( nSingle % 2 == 0 )
{
nSingle = 0;
nLineNum = 0;
nDescLine++;
nCharIndex[nDescLine] = i + 1;
}
else
{
nDescLine++;
nCharIndex[nDescLine] = i - ( nLineNum - nMaxLen );
i -= nLineNum - 2;
nSingle = 0;
nLineNum = 0;
}
}
}
if ( nLineNum < nMaxLen && nLineNum != 0 )
{
nDescLine++ ;
nCharIndex[nDescLine] = i;
}
char strTemp[32] ="";
int nOffset = 0;
for (i = 0; i < nDescLine; i++ )
{
strncpy ( strTemp, Static + nCharIndex[i], nCharIndex[i + 1] - nCharIndex[i] );
strTemp[nCharIndex[i + 1] - nCharIndex[i]] = '\0';
char szRegionDes1[128] = "";
char szRegionDes2[128] = "";
char ss[2] ="";
int nIndex = 0;
for(int i=0;i<strlen(strTemp);i++)
{
ss[0] = strTemp[i];
ss[1] = strTemp[i+1];
if ( ( BYTE )ss[0] > 0x80 && ( BYTE )ss[0] < 0xfe)
{
i++;
nIndex++;
if (nIndex%2 == 0)
{
strncat(szRegionDes2,ss,2);
if (bTline)
strcat(szRegionDes1," \0");
else
strcat(szRegionDes1," \0");
}
else
{
strncat(szRegionDes1,ss,2);
if (bTline)
strcat(szRegionDes2," \0");
else
strcat(szRegionDes2," \0");
}
}
else
{
nIndex++;
if (nIndex%2 == 0)
{
strncat(szRegionDes2,ss,1);
strcat(szRegionDes1," \0");
}
else
{
strncat(szRegionDes1,ss,1);
strcat(szRegionDes2," \0");
}
}
}
const int nFontSize = 24;
if (bTline)
{
CMyPos posStr = {_REGIONDES_POSX, _REGIONDES_POSY};
if (dwTimePass < dwShowDelay)
{
CMyBitmap::ShowTString(posStr.x-nOffset, posStr.y, m_dwDesColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
}
else if (dwTimePass > dwShowDelay+dwStayTime)
{
CMyBitmap::ShowTString(posStr.x-nOffset, posStr.y , m_dwDesColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
CMyBitmap::ShowTString(posStr.x-nOffset, posStr.y , m_dwDesColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
}
else
CMyBitmap::ShowTString(posStr.x-nOffset, posStr.y, m_dwDesColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
nOffset += nFontSize;
}
else
{
CMyPos posStr = {_SCR_WIDTH/2 - nFontSize/2 * strlen(strTemp)/2, _REGIONNAME_POSY + 50};
if (dwTimePass < dwShowDelay)
{
CMyBitmap::ShowString(posStr.x, posStr.y + nOffset, m_dwDesColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
}
else if (dwTimePass > dwShowDelay+dwStayTime)
{
CMyBitmap::ShowString(posStr.x, posStr.y + nOffset, m_dwDesColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
}
else
{
CMyBitmap::ShowString(posStr.x, posStr.y + nOffset, m_dwDesColor | (dwAlpha << 24), szRegionDes1, (char*)_REGION_FONT, nFontSize, true);
CMyBitmap::ShowString(posStr.x, posStr.y +nOffset, m_dwDesColor | (dwAlpha << 24), szRegionDes2, (char*)_REGION_FONT, nFontSize, true);
}
nOffset += nFontSize;
}
}
return FALSE;
}
//-------------------------------------------------------------
DWORD CGameMap::CellIndexCounter()
{
DWORD dwAmount = m_sizeMap.iWidth*m_sizeMap.iHeight;
CellInfo* pMyCellInfo = m_pCellInfo;
if(!pMyCellInfo)
return NULL;
IndexLayerInfo info;
for(DWORD i = 0; i < dwAmount; i ++)
{
// search ...
DWORD dwIndexAmount = m_setIndexLayerInfo.size();
BOOL bFound = false;
for(DWORD j = 0; j < dwIndexAmount; j++)
{
if((pMyCellInfo->m_infoLayer.usTerrain == m_setIndexLayerInfo[j].usTerrain) &&
(pMyCellInfo->m_infoLayer.usMask == m_setIndexLayerInfo[j].usMask) &&
(pMyCellInfo->m_infoLayer.sAltitude == m_setIndexLayerInfo[j].sAltitude))
{
bFound = true;
break;
}
}
if(!bFound)
{
info.usTerrain = pMyCellInfo->m_infoLayer.usTerrain;
info.usMask = pMyCellInfo->m_infoLayer.usMask;
info.sAltitude = pMyCellInfo->m_infoLayer.sAltitude;
m_setIndexLayerInfo.push_back(info);
}
pMyCellInfo ++;
}
return m_setIndexLayerInfo.size();
}
//-------------------------------------------------------------
void CGameMap::CellIndexUniteCounter(DWORD &dwSame, DWORD &dwDif)
{
CellInfo infoCell;
dwSame = dwDif = 0;
if(!m_pCellInfo)
{
return;
}
int j = 0;
const DWORD dwStepLength = 8;
DWORD dwStepAmount = m_sizeMap.iWidth/dwStepLength;
if(m_sizeMap.iWidth%dwStepLength != 0)
dwStepAmount ++;
for(int i = 0; i < m_sizeMap.iHeight; i ++)
{
for(int j = 0; j < dwStepAmount; j ++)
{
BOOL bSame = true;
for(int k = 0; k < dwStepLength; k ++)
{
if(j*dwStepLength+k >= m_sizeMap.iWidth)
{
bSame = false;
break;
}
if(k == 0)
{
CellInfo* pCellInfo = m_pCellInfo + i*m_sizeMap.iWidth + k * dwStepLength + j;
infoCell.m_infoLayer.usTerrain = pCellInfo->m_infoLayer.usTerrain;
infoCell.m_infoLayer.usMask = pCellInfo->m_infoLayer.usMask;
infoCell.m_infoLayer.sAltitude = pCellInfo->m_infoLayer.sAltitude;
}
else
{
CellInfo* pCellInfo = m_pCellInfo + i*m_sizeMap.iWidth + k * dwStepLength + j;
if((infoCell.m_infoLayer.usTerrain != pCellInfo->m_infoLayer.usTerrain) ||
(infoCell.m_infoLayer.usMask != pCellInfo->m_infoLayer.usMask) ||
(infoCell.m_infoLayer.sAltitude != pCellInfo->m_infoLayer.sAltitude))
{
bSame = false;
break;
}
}
}
if(bSame)
dwSame ++;
else
dwDif ++;
}
}
}
//----------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -