Confirmation popup when clearing the map in the map editor

This commit is contained in:
Yair Morgenstern
2020-10-08 15:34:31 +03:00
parent 36ed648621
commit 55d904e1cd
2 changed files with 25 additions and 31 deletions

View File

@ -690,26 +690,17 @@ class MapUnit {
civInfo.addNotification("An enemy [Citadel] has destroyed our [$name]", currentTile.position, Color.RED)
// todo - add notification for attacking civ
destroy()
} else {
civInfo.addNotification("An enemy [Citadel] has attacked our [$name]", currentTile.position, Color.RED)
}
} else civInfo.addNotification("An enemy [Citadel] has attacked our [$name]", currentTile.position, Color.RED)
}
}
fun matchesCategory(category:String): Boolean {
if (category == type.name)
return true
if (category == name)
return true
if ((category == "Wounded" || category == "wounded units") && health < 100)
return true
if ((category == "Land" || category == "land units") && type.isLandUnit())
return true
if ((category == "Water" || category == "water units") && type.isWaterUnit())
return true
if ((category == "Air" || category == "air units") && type.isAirUnit())
return true
if (category == type.name) return true
if (category == name) return true
if ((category == "Wounded" || category == "wounded units") && health < 100) return true
if ((category == "Land" || category == "land units") && type.isLandUnit()) return true
if ((category == "Water" || category == "water units") && type.isWaterUnit()) return true
if ((category == "Air" || category == "air units") && type.isAirUnit()) return true
return false
}

View File

@ -51,15 +51,17 @@ class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorS
private fun Popup.addClearCurrentMapButton() {
val clearCurrentMapButton = "Clear current map".toTextButton()
clearCurrentMapButton.onClick {
YesNoPopup("Are you sure you want to clear the entire map?", {
for (tileGroup in mapEditorScreen.mapHolder.tileGroups.values) {
val tile = tileGroup.tileInfo
tile.baseTerrain = Constants.ocean
tile.terrainFeature = null
tile.naturalWonder = null
tile.hasBottomRiver=false
tile.hasBottomLeftRiver=false
tile.hasBottomRightRiver=false
tile.hasBottomRiver = false
tile.hasBottomLeftRiver = false
tile.hasBottomRightRiver = false
tile.resource = null
tile.improvement = null
tile.improvementInProgress = null
@ -69,6 +71,7 @@ class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorS
tileGroup.update()
}
}, mapEditorScreen).open()
}
add(clearCurrentMapButton).row()
}