diff options
| author | oy <Tom_Adams@web.de> | 2011-02-18 10:49:54 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-02-18 10:49:54 +0100 |
| commit | ae94c36f547a699b1657b0b2284fb14f04da0d41 (patch) | |
| tree | 244c9f03991a680219ec5b4e6a6a2cc51a38a7be /src/game | |
| parent | b2f66978c981351727ded03bca5d87b1b990b2d6 (diff) | |
| download | zcatch-ae94c36f547a699b1657b0b2284fb14f04da0d41.tar.gz zcatch-ae94c36f547a699b1657b0b2284fb14f04da0d41.zip | |
made game tile construction in the editor more usable
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/editor/ed_layer_tiles.cpp | 4 | ||||
| -rw-r--r-- | src/game/editor/ed_popups.cpp | 49 |
2 files changed, 46 insertions, 7 deletions
diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index c8425947..57b77e36 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -344,8 +344,8 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox) int h = min(gl->m_Height, m_Height); for(int y = 0; y < h; y++) for(int x = 0; x < w; x++) - if(gl->m_pTiles[y*gl->m_Width+x].m_Index >= TILE_AIR && gl->m_pTiles[y*gl->m_Width+x].m_Index <= TILE_NOHOOK) - gl->m_pTiles[y*gl->m_Width+x].m_Index = m_pTiles[y*m_Width+x].m_Index?TILE_AIR+Result:TILE_AIR; + if(m_pTiles[y*m_Width+x].m_Index) + gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR+Result; return 1; } diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 3ab4ab49..c34a1b1b 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -87,12 +87,51 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) static int s_DeleteButton = 0; // don't allow deletion of game group - if(pEditor->m_Map.m_pGameGroup != pEditor->GetSelectedGroup() && - pEditor->DoButton_Editor(&s_DeleteButton, Localize("Delete group"), 0, &Button, 0, Localize("Delete group"))) + if(pEditor->m_Map.m_pGameGroup != pEditor->GetSelectedGroup()) { - pEditor->m_Map.DeleteGroup(pEditor->m_SelectedGroup); - pEditor->m_SelectedGroup = max(0, pEditor->m_SelectedGroup-1); - return 1; + if(pEditor->DoButton_Editor(&s_DeleteButton, Localize("Delete group"), 0, &Button, 0, Localize("Delete group"))) + { + pEditor->m_Map.DeleteGroup(pEditor->m_SelectedGroup); + pEditor->m_SelectedGroup = max(0, pEditor->m_SelectedGroup-1); + return 1; + } + } + else + { + if(pEditor->DoButton_Editor(&s_DeleteButton, Localize("Clean-up game tiles"), 0, &Button, 0, Localize("Removes game tiles that aren't based on a layer"))) + { + // gather all tile layers + array<CLayerTiles*> Layers; + for(int i = 0; i < pEditor->m_Map.m_pGameGroup->m_lLayers.size(); ++i) + { + if(pEditor->m_Map.m_pGameGroup->m_lLayers[i] != pEditor->m_Map.m_pGameLayer && pEditor->m_Map.m_pGameGroup->m_lLayers[i]->m_Type == LAYERTYPE_TILES) + Layers.add(static_cast<CLayerTiles *>(pEditor->m_Map.m_pGameGroup->m_lLayers[i])); + } + + // search for unneeded game tiles + CLayerTiles *gl = pEditor->m_Map.m_pGameLayer; + for(int y = 0; y < gl->m_Height; ++y) + for(int x = 0; x < gl->m_Width; ++x) + { + if(gl->m_pTiles[y*gl->m_Width+x].m_Index > static_cast<unsigned char>(TILE_NOHOOK)) + continue; + + bool Found = false; + for(int i = 0; i < Layers.size(); ++i) + { + if(x < Layers[i]->m_Width && y < Layers[i]->m_Height && Layers[i]->m_pTiles[y*Layers[i]->m_Width+x].m_Index) + { + Found = true; + break; + } + } + + if(!Found) + gl->m_pTiles[y*gl->m_Width+x].m_Index = TILE_AIR; + } + + return 1; + } } // new tile layer |