mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed shifting for front layer and switch layer
This commit is contained in:
parent
743338ce95
commit
68c9323021
|
@ -477,6 +477,7 @@ public:
|
|||
CLayerFront(int w, int h);
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void Shift(int Direction);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
};
|
||||
|
||||
|
@ -489,6 +490,7 @@ public:
|
|||
CTeleTile *m_pSwitchTile;
|
||||
|
||||
virtual void Resize(int NewW, int NewH);
|
||||
virtual void Shift(int Direction);
|
||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||
virtual void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect);
|
||||
};
|
||||
|
|
|
@ -869,6 +869,42 @@ void CLayerFront::Resize(int NewW, int NewH)
|
|||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerFront::Shift(int Direction)
|
||||
{
|
||||
CLayerTiles::Shift(Direction);
|
||||
|
||||
switch(Direction)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
// left
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
mem_move(&m_pTiles[y*m_Width], &m_pTiles[y*m_Width+1], (m_Width-1)*sizeof(CTile));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
// right
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
mem_move(&m_pTiles[y*m_Width+1], &m_pTiles[y*m_Width], (m_Width-1)*sizeof(CTile));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
// up
|
||||
for(int y = 0; y < m_Height-1; ++y)
|
||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+1)*m_Width], m_Width*sizeof(CTile));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
{
|
||||
// down
|
||||
for(int y = m_Height-1; y > 0; --y)
|
||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-1)*m_Width], m_Width*sizeof(CTile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerFront::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
if(m_Readonly)
|
||||
|
@ -931,6 +967,42 @@ void CLayerSwitch::Resize(int NewW, int NewH)
|
|||
m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
|
||||
}
|
||||
|
||||
void CLayerSwitch::Shift(int Direction)
|
||||
{
|
||||
CLayerTiles::Shift(Direction);
|
||||
|
||||
switch(Direction)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
// left
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
mem_move(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[y*m_Width+1], (m_Width-1)*sizeof(CTeleTile));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
// right
|
||||
for(int y = 0; y < m_Height; ++y)
|
||||
mem_move(&m_pSwitchTile[y*m_Width+1], &m_pSwitchTile[y*m_Width], (m_Width-1)*sizeof(CTeleTile));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
// up
|
||||
for(int y = 0; y < m_Height-1; ++y)
|
||||
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y+1)*m_Width], m_Width*sizeof(CTeleTile));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
{
|
||||
// down
|
||||
for(int y = m_Height-1; y > 0; --y)
|
||||
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y-1)*m_Width], m_Width*sizeof(CTeleTile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLayerSwitch::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||
{
|
||||
CLayerSwitch *l = (CLayerSwitch *)pBrush;
|
||||
|
|
Loading…
Reference in a new issue