void UPaperTileMap::ResizeMap(int32 NewWidth, int32 NewHeight, bool bForceResize) { if (bForceResize || (NewWidth != MapWidth) || (NewHeight != MapHeight)) { MapWidth = FMath::Max(NewWidth, 1); MapHeight = FMath::Max(NewHeight, 1); // Resize all of the existing layers for (int32 LayerIndex = 0; LayerIndex < TileLayers.Num(); ++LayerIndex) { UPaperTileLayer* TileLayer = TileLayers[LayerIndex]; TileLayer->Modify(); TileLayer->ResizeMap(MapWidth, MapHeight); } } }
void STileLayerList::MergeLayerDown() { if (UPaperTileMap* TileMap = TileMapPtr.Get()) { const int32 SourceIndex = GetSelectionIndex(); const int32 TargetIndex = SourceIndex + 1; if ((SourceIndex != INDEX_NONE) && (TargetIndex != INDEX_NONE)) { const FScopedTransaction Transaction(LOCTEXT("TileMapMergeLayerDown", "Merge Layer Down")); TileMap->SetFlags(RF_Transactional); TileMap->Modify(); UPaperTileLayer* SourceLayer = TileMap->TileLayers[SourceIndex]; UPaperTileLayer* TargetLayer = TileMap->TileLayers[TargetIndex]; TargetLayer->SetFlags(RF_Transactional); TargetLayer->Modify(); // Copy the non-empty tiles from the source to the target layer for (int32 Y = 0; Y < SourceLayer->LayerWidth; ++Y) { for (int32 X = 0; X < SourceLayer->LayerWidth; ++X) { FPaperTileInfo TileInfo = SourceLayer->GetCell(X, Y); if (TileInfo.IsValid()) { TargetLayer->SetCell(X, Y, TileInfo); } } } // Remove the source layer TileMap->TileLayers.RemoveAt(SourceIndex); // Update viewers PostEditNotfications(); } } }