mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
hookthrough shortcut now works for game and front
This commit is contained in:
parent
c583e87b90
commit
70ffbbbbf9
|
@ -507,8 +507,8 @@ public:
|
||||||
CLayerTiles(int w, int h);
|
CLayerTiles(int w, int h);
|
||||||
~CLayerTiles();
|
~CLayerTiles();
|
||||||
|
|
||||||
virtual CTile GetTile(int x, int y, bool force=false);
|
virtual CTile GetTile(int x, int y);
|
||||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
virtual void SetTile(int x, int y, CTile tile);
|
||||||
|
|
||||||
virtual void Resize(int NewW, int NewH);
|
virtual void Resize(int NewW, int NewH);
|
||||||
virtual void Shift(int Direction);
|
virtual void Shift(int Direction);
|
||||||
|
@ -593,8 +593,8 @@ public:
|
||||||
CLayerGame(int w, int h);
|
CLayerGame(int w, int h);
|
||||||
~CLayerGame();
|
~CLayerGame();
|
||||||
|
|
||||||
virtual CTile GetTile(int x, int y, bool force=false);
|
virtual CTile GetTile(int x, int y);
|
||||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
virtual void SetTile(int x, int y, CTile tile);
|
||||||
|
|
||||||
virtual int RenderProperties(CUIRect *pToolbox);
|
virtual int RenderProperties(CUIRect *pToolbox);
|
||||||
};
|
};
|
||||||
|
@ -1088,8 +1088,8 @@ public:
|
||||||
|
|
||||||
virtual void Resize(int NewW, int NewH);
|
virtual void Resize(int NewW, int NewH);
|
||||||
virtual void Shift(int Direction);
|
virtual void Shift(int Direction);
|
||||||
virtual CTile GetTile(int x, int y, bool force=false);
|
virtual CTile GetTile(int x, int y);
|
||||||
virtual void SetTile(int x, int y, CTile tile, bool force=false);
|
virtual void SetTile(int x, int y, CTile tile);
|
||||||
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,40 +14,38 @@ CLayerGame::~CLayerGame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CTile CLayerGame::GetTile(int x, int y, bool force)
|
CTile CLayerGame::GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
if(!force && m_pEditor->m_Map.m_pFrontLayer && GetTile(x, y, true).m_Index == TILE_NOHOOK && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT)
|
if(m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT) {
|
||||||
{
|
CTile through_cut = {TILE_THROUGH_CUT};
|
||||||
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
|
return through_cut;
|
||||||
return throughcut;
|
|
||||||
} else {
|
} else {
|
||||||
return m_pTiles[y*m_Width+x];
|
return CLayerTiles::GetTile(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerGame::SetTile(int x, int y, CTile tile, bool force)
|
void CLayerGame::SetTile(int x, int y, CTile tile)
|
||||||
{
|
{
|
||||||
if(!force && tile.m_Index == TILE_THROUGH_CUT) {
|
if(tile.m_Index == TILE_THROUGH_CUT) {
|
||||||
if(!m_pEditor->m_Map.m_pFrontLayer) {
|
if(!m_pEditor->m_Map.m_pFrontLayer) {
|
||||||
CLayer *l = new CLayerFront(m_Width, m_Height);
|
CLayer *l = new CLayerFront(m_Width, m_Height);
|
||||||
m_pEditor->m_Map.MakeFrontLayer(l);
|
m_pEditor->m_Map.MakeFrontLayer(l);
|
||||||
m_pEditor->m_Map.m_lGroups[m_pEditor->m_SelectedGroup]->AddLayer(l);
|
m_pEditor->m_Map.m_lGroups[m_pEditor->m_SelectedGroup]->AddLayer(l);
|
||||||
}
|
}
|
||||||
CTile nohook = {TILE_NOHOOK, 0, 0, 0};
|
CTile nohook = {TILE_NOHOOK};
|
||||||
SetTile(x, y, nohook, true);
|
CLayerTiles::SetTile(x, y, nohook);
|
||||||
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
|
CTile through_cut = {TILE_THROUGH_CUT};
|
||||||
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, throughcut, true);
|
m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, through_cut);
|
||||||
} else {
|
} else {
|
||||||
if(!force && m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
|
if(m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT) {
|
||||||
CTile air = {TILE_AIR, 0, 0, 0};
|
CTile air = {TILE_AIR};
|
||||||
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, air, true);
|
m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, air);
|
||||||
}
|
}
|
||||||
// set normal game tile
|
|
||||||
if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidGameTile(tile.m_Index)) {
|
if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidGameTile(tile.m_Index)) {
|
||||||
m_pTiles[y*m_Width+x] = tile;
|
CLayerTiles::SetTile(x, y, tile);
|
||||||
} else {
|
} else {
|
||||||
CTile air = {TILE_AIR, 0, 0, 0};
|
CTile air = {TILE_AIR};
|
||||||
SetTile(x, y, air);
|
CLayerTiles::SetTile(x, y, air);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,12 @@ CLayerTiles::~CLayerTiles()
|
||||||
delete [] m_pTiles;
|
delete [] m_pTiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTile CLayerTiles::GetTile(int x, int y, bool force)
|
CTile CLayerTiles::GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
return m_pTiles[y*m_Width+x];
|
return m_pTiles[y*m_Width+x];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerTiles::SetTile(int x, int y, CTile tile, bool force)
|
void CLayerTiles::SetTile(int x, int y, CTile tile)
|
||||||
{
|
{
|
||||||
m_pTiles[y*m_Width+x] = tile;
|
m_pTiles[y*m_Width+x] = tile;
|
||||||
}
|
}
|
||||||
|
@ -1300,26 +1300,25 @@ CLayerFront::CLayerFront(int w, int h)
|
||||||
m_Front = 1;
|
m_Front = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTile CLayerFront::GetTile(int x, int y, bool force)
|
CTile CLayerFront::GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
if(!force && GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
|
return CLayerTiles::GetTile(x, y);
|
||||||
CTile air = {TILE_AIR, 0, 0, 0};
|
|
||||||
return air;
|
|
||||||
} else {
|
|
||||||
return m_pTiles[y*m_Width+x];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLayerFront::SetTile(int x, int y, CTile tile, bool force)
|
void CLayerFront::SetTile(int x, int y, CTile tile)
|
||||||
{
|
{
|
||||||
if(force || (GetTile(x, y, true).m_Index != TILE_THROUGH_CUT && tile.m_Index != TILE_THROUGH_CUT)) {
|
if(tile.m_Index == TILE_THROUGH_CUT) {
|
||||||
// set normal front tile
|
CTile nohook = {TILE_NOHOOK};
|
||||||
if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidFrontTile(tile.m_Index)) {
|
m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, nohook);
|
||||||
m_pTiles[y*m_Width+x] = tile;
|
} else if(tile.m_Index == TILE_AIR && CLayerTiles::GetTile(x, y).m_Index == TILE_THROUGH_CUT) {
|
||||||
} else {
|
CTile air = {TILE_AIR};
|
||||||
CTile air = {TILE_AIR, 0, 0, 0};
|
m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, air);
|
||||||
SetTile(x, y, air);
|
|
||||||
}
|
}
|
||||||
|
if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidFrontTile(tile.m_Index)) {
|
||||||
|
CLayerTiles::SetTile(x, y, tile);
|
||||||
|
} else {
|
||||||
|
CTile air = {TILE_AIR};
|
||||||
|
CLayerTiles::SetTile(x, y, air);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue