added "fixed brush rotating and flipping for tele and speeduplayer" by SushiTee

This commit is contained in:
GreYFoX 2011-04-17 17:59:02 +02:00
parent 81dd1a3439
commit 4c11e9460b
4 changed files with 141 additions and 8 deletions

View file

@ -255,7 +255,11 @@ void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote
cs = 0.5f;
}
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, pInfo->m_ColorFeet.a);
if(Alpha)
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, pInfo->m_ColorFeet.a*cs);
else
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, 1.0f);
IGraphics::CQuadItem QuadItem(Position.x+pFoot->m_X*AnimScale, Position.y+pFoot->m_Y*AnimScale, w, h);
Graphics()->QuadsDraw(&QuadItem, 1);
}

View file

@ -3370,7 +3370,7 @@ void CEditorMap::CreateDefault(int EntitiesTexture)
pQuad->m_aColors[2].b = pQuad->m_aColors[3].b = 255;
pGroup->AddLayer(pLayer);
// add game layer and front and reset the tele, speedup and switch layer pointers
// add game layer and reset front, tele, speedup and switch layer pointers
MakeGameGroup(NewGroup());
MakeGameLayer(new CLayerGame(50, 50));
m_pGameGroup->AddLayer(m_pGameLayer);

View file

@ -543,6 +543,8 @@ public:
ms_pUiGotContext = 0;
// DDRace
ms_FrontTexture = 0;
ms_TeleTexture = 0;
ms_SpeedupTexture = 0;
@ -800,6 +802,9 @@ public:
virtual void Resize(int NewW, int NewH);
virtual void Shift(int Direction);
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
virtual void BrushFlipX();
virtual void BrushFlipY();
virtual void BrushRotate(float Amount);
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
};
@ -817,6 +822,9 @@ public:
virtual void Resize(int NewW, int NewH);
virtual void Shift(int Direction);
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
virtual void BrushFlipX();
virtual void BrushFlipY();
virtual void BrushRotate(float Amount);
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
};

View file

@ -331,7 +331,7 @@ void CLayerTiles::BrushFlipX()
m_pTiles[y*m_Width+m_Width-1-x] = Tmp;
}
if(!m_Game)
if(!m_Game && !m_Tele && !m_Speedup)
for(int y = 0; y < m_Height; y++)
for(int x = 0; x < m_Width; x++)
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_HFLIP : TILEFLAG_VFLIP;
@ -347,7 +347,7 @@ void CLayerTiles::BrushFlipY()
m_pTiles[(m_Height-1-y)*m_Width+x] = Tmp;
}
if(!m_Game)
if(!m_Game && !m_Tele && !m_Speedup)
for(int y = 0; y < m_Height; y++)
for(int x = 0; x < m_Width; x++)
m_pTiles[y*m_Width+x].m_Flags ^= m_pTiles[y*m_Width+x].m_Flags&TILEFLAG_ROTATE ? TILEFLAG_VFLIP : TILEFLAG_HFLIP;
@ -369,7 +369,7 @@ void CLayerTiles::BrushRotate(float Amount)
for(int y = m_Height-1; y >= 0; --y, ++pDst)
{
*pDst = pTempData[y*m_Width+x];
if(!m_Game)
if(!m_Game && !m_Tele && !m_Speedup)
{
if(pDst->m_Flags&TILEFLAG_ROTATE)
pDst->m_Flags ^= (TILEFLAG_HFLIP|TILEFLAG_VFLIP);
@ -687,11 +687,8 @@ void CLayerTele::BrushDraw(CLayer *pBrush, float wx, float wy)
int sx = ConvertX(wx);
int sy = ConvertY(wy);
if(str_comp(l->m_aFileName, m_pEditor->m_aFileName))
{
m_pEditor->m_TeleNumber = l->m_TeleNum;
}
for(int y = 0; y < l->m_Height; y++)
for(int x = 0; x < l->m_Width; x++)
{
@ -733,6 +730,68 @@ void CLayerTele::BrushDraw(CLayer *pBrush, float wx, float wy)
}
}
void CLayerTele::BrushFlipX()
{
CLayerTiles::BrushFlipX();
for(int y = 0; y < m_Height; y++)
for(int x = 0; x < m_Width/2; x++)
{
CTeleTile Tmp = m_pTeleTile[y*m_Width+x];
m_pTeleTile[y*m_Width+x] = m_pTeleTile[y*m_Width+m_Width-1-x];
m_pTeleTile[y*m_Width+m_Width-1-x] = Tmp;
}
}
void CLayerTele::BrushFlipY()
{
CLayerTiles::BrushFlipY();
for(int y = 0; y < m_Height/2; y++)
for(int x = 0; x < m_Width; x++)
{
CTeleTile Tmp = m_pTeleTile[y*m_Width+x];
m_pTeleTile[y*m_Width+x] = m_pTeleTile[(m_Height-1-y)*m_Width+x];
m_pTeleTile[(m_Height-1-y)*m_Width+x] = Tmp;
}
}
void CLayerTele::BrushRotate(float Amount)
{
int Rotation = (round(360.0f*Amount/(pi*2))/90)%4; // 0=0°, 1=90°, 2=180°, 3=270°
if(Rotation < 0)
Rotation +=4;
if(Rotation == 1 || Rotation == 3)
{
// 90° rotation
CTeleTile *pTempData1 = new CTeleTile[m_Width*m_Height];
CTile *pTempData2 = new CTile[m_Width*m_Height];
mem_copy(pTempData1, m_pTeleTile, m_Width*m_Height*sizeof(CTeleTile));
mem_copy(pTempData2, m_pTiles, m_Width*m_Height*sizeof(CTile));
CTeleTile *pDst1 = m_pTeleTile;
CTile *pDst2 = m_pTiles;
for(int x = 0; x < m_Width; ++x)
for(int y = m_Height-1; y >= 0; --y, ++pDst1, ++pDst2)
{
*pDst1 = pTempData1[y*m_Width+x];
*pDst2 = pTempData2[y*m_Width+x];
}
int Temp = m_Width;
m_Width = m_Height;
m_Height = Temp;
delete[] pTempData1;
delete[] pTempData2;
}
if(Rotation == 2 || Rotation == 3)
{
BrushFlipX();
BrushFlipY();
}
}
void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
{
if(m_Readonly)
@ -914,6 +973,68 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
}
}
void CLayerSpeedup::BrushFlipX()
{
CLayerTiles::BrushFlipX();
for(int y = 0; y < m_Height; y++)
for(int x = 0; x < m_Width/2; x++)
{
CSpeedupTile Tmp = m_pSpeedupTile[y*m_Width+x];
m_pSpeedupTile[y*m_Width+x] = m_pSpeedupTile[y*m_Width+m_Width-1-x];
m_pSpeedupTile[y*m_Width+m_Width-1-x] = Tmp;
}
}
void CLayerSpeedup::BrushFlipY()
{
CLayerTiles::BrushFlipY();
for(int y = 0; y < m_Height/2; y++)
for(int x = 0; x < m_Width; x++)
{
CSpeedupTile Tmp = m_pSpeedupTile[y*m_Width+x];
m_pSpeedupTile[y*m_Width+x] = m_pSpeedupTile[(m_Height-1-y)*m_Width+x];
m_pSpeedupTile[(m_Height-1-y)*m_Width+x] = Tmp;
}
}
void CLayerSpeedup::BrushRotate(float Amount)
{
int Rotation = (round(360.0f*Amount/(pi*2))/90)%4; // 0=0°, 1=90°, 2=180°, 3=270°
if(Rotation < 0)
Rotation +=4;
if(Rotation == 1 || Rotation == 3)
{
// 90° rotation
CSpeedupTile *pTempData1 = new CSpeedupTile[m_Width*m_Height];
CTile *pTempData2 = new CTile[m_Width*m_Height];
mem_copy(pTempData1, m_pSpeedupTile, m_Width*m_Height*sizeof(CSpeedupTile));
mem_copy(pTempData2, m_pTiles, m_Width*m_Height*sizeof(CTile));
CSpeedupTile *pDst1 = m_pSpeedupTile;
CTile *pDst2 = m_pTiles;
for(int x = 0; x < m_Width; ++x)
for(int y = m_Height-1; y >= 0; --y, ++pDst1, ++pDst2)
{
*pDst1 = pTempData1[y*m_Width+x];
*pDst2 = pTempData2[y*m_Width+x];
}
int Temp = m_Width;
m_Width = m_Height;
m_Height = Temp;
delete[] pTempData1;
delete[] pTempData2;
}
if(Rotation == 2 || Rotation == 3)
{
BrushFlipX();
BrushFlipY();
}
}
void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
{
if(m_Readonly)