1#include <game/editor/editor.h>
2
3CLayerFront::CLayerFront(CEditor *pEditor, int w, int h) :
4 CLayerTiles(pEditor, w, h)
5{
6 str_copy(dst&: m_aName, src: "Front");
7 m_Front = 1;
8}
9
10void CLayerFront::SetTile(int x, int y, CTile Tile)
11{
12 if(Tile.m_Index == TILE_THROUGH_CUT)
13 {
14 CTile nohook = {.m_Index: TILE_NOHOOK};
15 m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, Tile: nohook); // NOLINT(bugprone-parent-virtual-call)
16 }
17 else if(Tile.m_Index == TILE_AIR && CLayerTiles::GetTile(x, y).m_Index == TILE_THROUGH_CUT)
18 {
19 CTile air = {.m_Index: TILE_AIR};
20 m_pEditor->m_Map.m_pGameLayer->CLayerTiles::SetTile(x, y, Tile: air); // NOLINT(bugprone-parent-virtual-call)
21 }
22 if(m_pEditor->m_AllowPlaceUnusedTiles || IsValidFrontTile(Index: Tile.m_Index))
23 {
24 CLayerTiles::SetTile(x, y, Tile);
25 }
26 else
27 {
28 CTile air = {.m_Index: TILE_AIR};
29 CLayerTiles::SetTile(x, y, Tile: air);
30 ShowPreventUnusedTilesWarning();
31 }
32}
33
34void CLayerFront::Resize(int NewW, int NewH)
35{
36 // resize tile data
37 CLayerTiles::Resize(NewW, NewH);
38
39 // resize gamelayer too
40 if(m_pEditor->m_Map.m_pGameLayer->m_Width != NewW || m_pEditor->m_Map.m_pGameLayer->m_Height != NewH)
41 m_pEditor->m_Map.m_pGameLayer->Resize(NewW, NewH);
42}
43
44const char *CLayerFront::TypeName() const
45{
46 return "front";
47}
48