2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2011-04-19 08:34:51 +00:00
|
|
|
#include "editor.h"
|
2008-01-12 12:27:55 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CLayerGame::CLayerGame(int w, int h) :
|
|
|
|
CLayerTiles(w, h)
|
2008-01-12 12:27:55 +00:00
|
|
|
{
|
2011-07-12 01:14:46 +00:00
|
|
|
str_copy(m_aName, "Game", sizeof(m_aName));
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Game = 1;
|
2008-01-12 12:27:55 +00:00
|
|
|
}
|
|
|
|
|
2022-02-14 23:32:04 +00:00
|
|
|
CLayerGame::~CLayerGame() = default;
|
2008-01-12 12:27:55 +00:00
|
|
|
|
2016-04-30 23:47:29 +00:00
|
|
|
CTile CLayerGame::GetTile(int x, int y)
|
2015-11-14 23:00:43 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
if(m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT)
|
|
|
|
{
|
2016-04-30 23:47:29 +00:00
|
|
|
CTile through_cut = {TILE_THROUGH_CUT};
|
|
|
|
return through_cut;
|
2020-09-26 19:41:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-30 23:47:29 +00:00
|
|
|
return CLayerTiles::GetTile(x, y);
|
2015-11-14 23:00:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 23:47:29 +00:00
|
|
|
void CLayerGame::SetTile(int x, int y, CTile tile)
|
2015-11-14 23:00:43 +00:00
|
|
|
{
|
2021-08-30 10:41:28 +00:00
|
|
|
if(tile.m_Index == TILE_THROUGH_CUT && m_pEditor->m_SelectEntitiesImage == "DDNet")
|
2020-09-26 19:41:58 +00:00
|
|
|
{
|
|
|
|
if(!m_pEditor->m_Map.m_pFrontLayer)
|
|
|
|
{
|
2015-11-14 23:00:43 +00:00
|
|
|
CLayer *l = new CLayerFront(m_Width, m_Height);
|
|
|
|
m_pEditor->m_Map.MakeFrontLayer(l);
|
2019-03-12 01:35:29 +00:00
|
|
|
m_pEditor->m_Map.m_pGameGroup->AddLayer(l);
|
2015-11-14 23:00:43 +00:00
|
|
|
}
|
2016-04-30 23:47:29 +00:00
|
|
|
CTile nohook = {TILE_NOHOOK};
|
|
|
|
CLayerTiles::SetTile(x, y, nohook);
|
|
|
|
CTile through_cut = {TILE_THROUGH_CUT};
|
2020-11-04 18:27:22 +00:00
|
|
|
m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, through_cut); // NOLINT(bugprone-parent-virtual-call)
|
2020-09-26 19:41:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-30 10:41:28 +00:00
|
|
|
if(m_pEditor->m_SelectEntitiesImage == "DDNet" && m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y).m_Index == TILE_THROUGH_CUT)
|
2020-09-26 19:41:58 +00:00
|
|
|
{
|
2016-04-30 23:47:29 +00:00
|
|
|
CTile air = {TILE_AIR};
|
2020-11-04 18:27:22 +00:00
|
|
|
m_pEditor->m_Map.m_pFrontLayer->CLayerTiles::SetTile(x, y, air); // NOLINT(bugprone-parent-virtual-call)
|
2015-11-14 23:00:43 +00:00
|
|
|
}
|
2020-09-26 19:41:58 +00:00
|
|
|
if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidGameTile(tile.m_Index))
|
|
|
|
{
|
2016-04-30 23:47:29 +00:00
|
|
|
CLayerTiles::SetTile(x, y, tile);
|
2020-09-26 19:41:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-30 23:47:29 +00:00
|
|
|
CTile air = {TILE_AIR};
|
|
|
|
CLayerTiles::SetTile(x, y, air);
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!m_pEditor->m_PreventUnusedTilesWasWarned)
|
|
|
|
{
|
2016-05-01 16:08:07 +00:00
|
|
|
m_pEditor->m_PopupEventType = m_pEditor->POPEVENT_PREVENTUNUSEDTILES;
|
|
|
|
m_pEditor->m_PopupEventActivated = true;
|
|
|
|
m_pEditor->m_PreventUnusedTilesWasWarned = true;
|
|
|
|
}
|
2016-04-29 14:53:19 +00:00
|
|
|
}
|
2015-11-14 23:00:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int CLayerGame::RenderProperties(CUIRect *pToolbox)
|
2008-01-12 12:27:55 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int r = CLayerTiles::RenderProperties(pToolbox);
|
|
|
|
m_Image = -1;
|
2008-01-13 22:03:32 +00:00
|
|
|
return r;
|
2008-01-12 12:27:55 +00:00
|
|
|
}
|