int ret = JOptionPane.showConfirmDialog(editor.getAppFrame(),
"Do you wish to merge tile images, and create a new tile set?",
"Merge Tiles?", JOptionPane.YES_NO_CANCEL_OPTION);
if (ret == JOptionPane.YES_OPTION) {
TileMergeHelper tmh = new TileMergeHelper(map);
int len = map.getTotalLayers();
//TODO: Add a dialog option: "Yes, visible only"
TileLayer newLayer = tmh.merge(0, len, true);
map.removeAllLayers();
map.addLayer(newLayer);
newLayer.setName("Merged Layer");
map.addTileset(tmh.getSet());
editor.setCurrentLayer(0);
}
else if (ret == JOptionPane.NO_OPTION) {
while (map.getTotalLayers() > 1) {
map.mergeLayerDown(editor.getCurrentLayerIndex());