fixed editor zooming if gui is not active
[twcon.git] / src / game / layers.cpp
blob6deb082977fb72781c3f952ad9f3ecc40b681ddb
1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #include "layers.h"
5 CLayers::CLayers()
7 m_GroupsNum = 0;
8 m_GroupsStart = 0;
9 m_LayersNum = 0;
10 m_LayersStart = 0;
11 m_pGameGroup = 0;
12 m_pGameLayer = 0;
13 m_pMap = 0;
16 void CLayers::Init(class IKernel *pKernel)
18 m_pMap = pKernel->RequestInterface<IMap>();
19 m_pMap->GetType(MAPITEMTYPE_GROUP, &m_GroupsStart, &m_GroupsNum);
20 m_pMap->GetType(MAPITEMTYPE_LAYER, &m_LayersStart, &m_LayersNum);
22 for(int g = 0; g < NumGroups(); g++)
24 CMapItemGroup *pGroup = GetGroup(g);
25 for(int l = 0; l < pGroup->m_NumLayers; l++)
27 CMapItemLayer *pLayer = GetLayer(pGroup->m_StartLayer+l);
29 if(pLayer->m_Type == LAYERTYPE_TILES)
31 CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer);
32 if(pTilemap->m_Flags&TILESLAYERFLAG_GAME)
34 m_pGameLayer = pTilemap;
35 m_pGameGroup = pGroup;
37 // make sure the game group has standard settings
38 m_pGameGroup->m_OffsetX = 0;
39 m_pGameGroup->m_OffsetY = 0;
40 m_pGameGroup->m_ParallaxX = 100;
41 m_pGameGroup->m_ParallaxY = 100;
43 if(m_pGameGroup->m_Version >= 2)
45 m_pGameGroup->m_UseClipping = 0;
46 m_pGameGroup->m_ClipX = 0;
47 m_pGameGroup->m_ClipY = 0;
48 m_pGameGroup->m_ClipW = 0;
49 m_pGameGroup->m_ClipH = 0;
52 break;
59 CMapItemGroup *CLayers::GetGroup(int Index) const
61 return static_cast<CMapItemGroup *>(m_pMap->GetItem(m_GroupsStart+Index, 0, 0));
64 CMapItemLayer *CLayers::GetLayer(int Index) const
66 return static_cast<CMapItemLayer *>(m_pMap->GetItem(m_LayersStart+Index, 0, 0));