mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Editor feature: Add possibility to set how far to shift layer
This commit is contained in:
parent
726cf67348
commit
6adb99608e
|
@ -4122,6 +4122,7 @@ void CEditor::Reset(bool CreateDefault)
|
||||||
m_UndoRunning = false;
|
m_UndoRunning = false;
|
||||||
|
|
||||||
m_ShowEnvelopePreview = 0;
|
m_ShowEnvelopePreview = 0;
|
||||||
|
m_ShiftBy = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEditor::GetLineDistance()
|
int CEditor::GetLineDistance()
|
||||||
|
|
|
@ -805,6 +805,7 @@ public:
|
||||||
static const void *ms_pUiGotContext;
|
static const void *ms_pUiGotContext;
|
||||||
|
|
||||||
CEditorMap m_Map;
|
CEditorMap m_Map;
|
||||||
|
int m_ShiftBy;
|
||||||
|
|
||||||
static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser);
|
static void EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser);
|
||||||
|
|
||||||
|
|
|
@ -479,34 +479,36 @@ void CLayerTiles::Resize(int NewW, int NewH)
|
||||||
|
|
||||||
void CLayerTiles::Shift(int Direction)
|
void CLayerTiles::Shift(int Direction)
|
||||||
{
|
{
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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));
|
mem_move(&m_pTiles[y*m_Width], &m_pTiles[y*m_Width+o], (m_Width-o)*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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));
|
mem_move(&m_pTiles[y*m_Width+o], &m_pTiles[y*m_Width], (m_Width-o)*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+1)*m_Width], m_Width*sizeof(CTile));
|
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+o)*m_Width], m_Width*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-1)*m_Width], m_Width*sizeof(CTile));
|
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-o)*m_Width], m_Width*sizeof(CTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,6 +643,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
PROP_WIDTH=0,
|
PROP_WIDTH=0,
|
||||||
PROP_HEIGHT,
|
PROP_HEIGHT,
|
||||||
PROP_SHIFT,
|
PROP_SHIFT,
|
||||||
|
PROP_SHIFT_BY,
|
||||||
PROP_IMAGE,
|
PROP_IMAGE,
|
||||||
PROP_COLOR,
|
PROP_COLOR,
|
||||||
PROP_COLOR_ENV,
|
PROP_COLOR_ENV,
|
||||||
|
@ -658,6 +661,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
{"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
|
{"Width", m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000},
|
||||||
{"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
|
{"Height", m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000},
|
||||||
{"Shift", 0, PROPTYPE_SHIFT, 0, 0},
|
{"Shift", 0, PROPTYPE_SHIFT, 0, 0},
|
||||||
|
{"Shift by", m_pEditor->m_ShiftBy, PROPTYPE_INT_SCROLL, 1, 1000000000},
|
||||||
{"Image", m_Image, PROPTYPE_IMAGE, 0, 0},
|
{"Image", m_Image, PROPTYPE_IMAGE, 0, 0},
|
||||||
{"Color", Color, PROPTYPE_COLOR, 0, 0},
|
{"Color", Color, PROPTYPE_COLOR, 0, 0},
|
||||||
{"Color Env", m_ColorEnv+1, PROPTYPE_INT_STEP, 0, m_pEditor->m_Map.m_lEnvelopes.size()+1},
|
{"Color Env", m_ColorEnv+1, PROPTYPE_INT_STEP, 0, m_pEditor->m_Map.m_lEnvelopes.size()+1},
|
||||||
|
@ -667,8 +671,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
|
|
||||||
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this || m_pEditor->m_Map.m_pTuneLayer == this) // remove the image and color properties if this is the game/tele/speedup/front/switch layer
|
if(m_pEditor->m_Map.m_pGameLayer == this || m_pEditor->m_Map.m_pTeleLayer == this || m_pEditor->m_Map.m_pSpeedupLayer == this || m_pEditor->m_Map.m_pFrontLayer == this || m_pEditor->m_Map.m_pSwitchLayer == this || m_pEditor->m_Map.m_pTuneLayer == this) // remove the image and color properties if this is the game/tele/speedup/front/switch layer
|
||||||
{
|
{
|
||||||
aProps[3].m_pName = 0;
|
|
||||||
aProps[4].m_pName = 0;
|
aProps[4].m_pName = 0;
|
||||||
|
aProps[5].m_pName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s_aIds[NUM_PROPS] = {0};
|
static int s_aIds[NUM_PROPS] = {0};
|
||||||
|
@ -683,6 +687,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
||||||
Resize(m_Width, NewVal);
|
Resize(m_Width, NewVal);
|
||||||
else if(Prop == PROP_SHIFT)
|
else if(Prop == PROP_SHIFT)
|
||||||
Shift(NewVal);
|
Shift(NewVal);
|
||||||
|
else if(Prop == PROP_SHIFT_BY)
|
||||||
|
m_pEditor->m_ShiftBy = NewVal;
|
||||||
else if(Prop == PROP_IMAGE)
|
else if(Prop == PROP_IMAGE)
|
||||||
{
|
{
|
||||||
if (NewVal == -1)
|
if (NewVal == -1)
|
||||||
|
@ -771,6 +777,7 @@ void CLayerTele::Resize(int NewW, int NewH)
|
||||||
void CLayerTele::Shift(int Direction)
|
void CLayerTele::Shift(int Direction)
|
||||||
{
|
{
|
||||||
CLayerTiles::Shift(Direction);
|
CLayerTiles::Shift(Direction);
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
|
@ -778,28 +785,28 @@ void CLayerTele::Shift(int Direction)
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pTeleTile[y*m_Width], &m_pTeleTile[y*m_Width+1], (m_Width-1)*sizeof(CTeleTile));
|
mem_move(&m_pTeleTile[y*m_Width], &m_pTeleTile[y*m_Width+o], (m_Width-o)*sizeof(CTeleTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pTeleTile[y*m_Width+1], &m_pTeleTile[y*m_Width], (m_Width-1)*sizeof(CTeleTile));
|
mem_move(&m_pTeleTile[y*m_Width+o], &m_pTeleTile[y*m_Width], (m_Width-o)*sizeof(CTeleTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pTeleTile[y*m_Width], &m_pTeleTile[(y+1)*m_Width], m_Width*sizeof(CTeleTile));
|
mem_copy(&m_pTeleTile[y*m_Width], &m_pTeleTile[(y+o)*m_Width], m_Width*sizeof(CTeleTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pTeleTile[y*m_Width], &m_pTeleTile[(y-1)*m_Width], m_Width*sizeof(CTeleTile));
|
mem_copy(&m_pTeleTile[y*m_Width], &m_pTeleTile[(y-o)*m_Width], m_Width*sizeof(CTeleTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,6 +1015,7 @@ void CLayerSpeedup::Resize(int NewW, int NewH)
|
||||||
void CLayerSpeedup::Shift(int Direction)
|
void CLayerSpeedup::Shift(int Direction)
|
||||||
{
|
{
|
||||||
CLayerTiles::Shift(Direction);
|
CLayerTiles::Shift(Direction);
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
|
@ -1015,28 +1023,28 @@ void CLayerSpeedup::Shift(int Direction)
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[y*m_Width+1], (m_Width-1)*sizeof(CSpeedupTile));
|
mem_move(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[y*m_Width+o], (m_Width-o)*sizeof(CSpeedupTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pSpeedupTile[y*m_Width+1], &m_pSpeedupTile[y*m_Width], (m_Width-1)*sizeof(CSpeedupTile));
|
mem_move(&m_pSpeedupTile[y*m_Width+o], &m_pSpeedupTile[y*m_Width], (m_Width-o)*sizeof(CSpeedupTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[(y+1)*m_Width], m_Width*sizeof(CSpeedupTile));
|
mem_copy(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[(y+o)*m_Width], m_Width*sizeof(CSpeedupTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[(y-1)*m_Width], m_Width*sizeof(CSpeedupTile));
|
mem_copy(&m_pSpeedupTile[y*m_Width], &m_pSpeedupTile[(y-o)*m_Width], m_Width*sizeof(CSpeedupTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1248,6 +1256,7 @@ void CLayerFront::Resize(int NewW, int NewH)
|
||||||
void CLayerFront::Shift(int Direction)
|
void CLayerFront::Shift(int Direction)
|
||||||
{
|
{
|
||||||
CLayerTiles::Shift(Direction);
|
CLayerTiles::Shift(Direction);
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
|
@ -1255,28 +1264,28 @@ void CLayerFront::Shift(int Direction)
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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));
|
mem_move(&m_pTiles[y*m_Width], &m_pTiles[y*m_Width+o], (m_Width-o)*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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));
|
mem_move(&m_pTiles[y*m_Width+o], &m_pTiles[y*m_Width], (m_Width-o)*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+1)*m_Width], m_Width*sizeof(CTile));
|
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y+o)*m_Width], m_Width*sizeof(CTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-1)*m_Width], m_Width*sizeof(CTile));
|
mem_copy(&m_pTiles[y*m_Width], &m_pTiles[(y-o)*m_Width], m_Width*sizeof(CTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1345,6 +1354,7 @@ void CLayerSwitch::Resize(int NewW, int NewH)
|
||||||
void CLayerSwitch::Shift(int Direction)
|
void CLayerSwitch::Shift(int Direction)
|
||||||
{
|
{
|
||||||
CLayerTiles::Shift(Direction);
|
CLayerTiles::Shift(Direction);
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
|
@ -1352,28 +1362,28 @@ void CLayerSwitch::Shift(int Direction)
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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(CSwitchTile));
|
mem_move(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[y*m_Width+o], (m_Width-o)*sizeof(CSwitchTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
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(CSwitchTile));
|
mem_move(&m_pSwitchTile[y*m_Width+o], &m_pSwitchTile[y*m_Width], (m_Width-o)*sizeof(CSwitchTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y+1)*m_Width], m_Width*sizeof(CSwitchTile));
|
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y+o)*m_Width], m_Width*sizeof(CSwitchTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y-1)*m_Width], m_Width*sizeof(CSwitchTile));
|
mem_copy(&m_pSwitchTile[y*m_Width], &m_pSwitchTile[(y-o)*m_Width], m_Width*sizeof(CSwitchTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1554,6 +1564,7 @@ void CLayerTune::Resize(int NewW, int NewH)
|
||||||
void CLayerTune::Shift(int Direction)
|
void CLayerTune::Shift(int Direction)
|
||||||
{
|
{
|
||||||
CLayerTiles::Shift(Direction);
|
CLayerTiles::Shift(Direction);
|
||||||
|
int o = m_pEditor->m_ShiftBy;
|
||||||
|
|
||||||
switch(Direction)
|
switch(Direction)
|
||||||
{
|
{
|
||||||
|
@ -1561,28 +1572,28 @@ void CLayerTune::Shift(int Direction)
|
||||||
{
|
{
|
||||||
// left
|
// left
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pTuneTile[y*m_Width], &m_pTuneTile[y*m_Width+1], (m_Width-1)*sizeof(CTuneTile));
|
mem_move(&m_pTuneTile[y*m_Width], &m_pTuneTile[y*m_Width+o], (m_Width-o)*sizeof(CTuneTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
// right
|
// right
|
||||||
for(int y = 0; y < m_Height; ++y)
|
for(int y = 0; y < m_Height; ++y)
|
||||||
mem_move(&m_pTuneTile[y*m_Width+1], &m_pTuneTile[y*m_Width], (m_Width-1)*sizeof(CTuneTile));
|
mem_move(&m_pTuneTile[y*m_Width+o], &m_pTuneTile[y*m_Width], (m_Width-o)*sizeof(CTuneTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
// up
|
// up
|
||||||
for(int y = 0; y < m_Height-1; ++y)
|
for(int y = 0; y < m_Height-o; ++y)
|
||||||
mem_copy(&m_pTuneTile[y*m_Width], &m_pTuneTile[(y+1)*m_Width], m_Width*sizeof(CTuneTile));
|
mem_copy(&m_pTuneTile[y*m_Width], &m_pTuneTile[(y+o)*m_Width], m_Width*sizeof(CTuneTile));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// down
|
// down
|
||||||
for(int y = m_Height-1; y > 0; --y)
|
for(int y = m_Height-o; y >= o; --y)
|
||||||
mem_copy(&m_pTuneTile[y*m_Width], &m_pTuneTile[(y-1)*m_Width], m_Width*sizeof(CTuneTile));
|
mem_copy(&m_pTuneTile[y*m_Width], &m_pTuneTile[(y-o)*m_Width], m_Width*sizeof(CTuneTile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue