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

View File

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