Resolved #606 - Added "Annex or raze city" popup
This commit is contained in:
parent
6cd925cf78
commit
350963d182
5 changed files with 26 additions and 6 deletions
|
@ -32,7 +32,7 @@ class NextTurnAutomation{
|
|||
}
|
||||
|
||||
private fun buyBuildingOrUnit(civInfo: CivilizationInfo) {
|
||||
//allow ai spending money to purchase building & unit. Buying staff has slightly lower priority than buying tech.
|
||||
//allow AI spending money to purchase building & unit. Buying staff has slightly lower priority than buying tech.
|
||||
for (city in civInfo.cities.sortedByDescending{ it.population.population }) {
|
||||
val construction = city.cityConstructions.getCurrentConstruction()
|
||||
if (construction.canBePurchased()
|
||||
|
|
|
@ -162,6 +162,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
|
||||
val enemyCiv = city.civInfo
|
||||
attacker.getCivInfo().addNotification("We have conquered the city of [${city.name}]!",city.location, Color.RED)
|
||||
attacker.getCivInfo().popupAlerts.add(PopupAlert(AlertType.CityConquered,city.name))
|
||||
|
||||
city.getCenterTile().apply {
|
||||
if(militaryUnit!=null) militaryUnit!!.destroy()
|
||||
|
|
|
@ -3,7 +3,8 @@ package com.unciv.logic.civilization
|
|||
enum class AlertType{
|
||||
WarDeclaration,
|
||||
Defeated,
|
||||
FirstContact
|
||||
FirstContact,
|
||||
CityConquered
|
||||
}
|
||||
|
||||
class PopupAlert (val type:AlertType, val value:String)
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.Nation
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
|
@ -336,15 +337,18 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert):Popup
|
|||
return button
|
||||
}
|
||||
|
||||
init {
|
||||
val otherCiv = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
val translatedNation = otherCiv.getTranslatedNation()
|
||||
fun addLeaderName(translatedNation:Nation){
|
||||
val otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr()
|
||||
add(otherCivLeaderName.toLabel())
|
||||
addSeparator()
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
when(popupAlert.type){
|
||||
AlertType.WarDeclaration -> {
|
||||
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation()
|
||||
addLeaderName(translatedNation)
|
||||
addGoodSizedLabel(translatedNation.declaringWar).row()
|
||||
val responseTable = Table()
|
||||
responseTable.add(getCloseButton("You'll pay for this!"))
|
||||
|
@ -352,13 +356,26 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert):Popup
|
|||
add(responseTable)
|
||||
}
|
||||
AlertType.Defeated -> {
|
||||
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation()
|
||||
addLeaderName(translatedNation)
|
||||
addGoodSizedLabel(translatedNation.defeated).row()
|
||||
add(getCloseButton("Farewell."))
|
||||
}
|
||||
AlertType.FirstContact -> {
|
||||
val translatedNation = worldScreen.gameInfo.getCivilization(popupAlert.value).getTranslatedNation()
|
||||
addLeaderName(translatedNation)
|
||||
addGoodSizedLabel(translatedNation.introduction).row()
|
||||
add(getCloseButton("A pleasure to meet you."))
|
||||
}
|
||||
AlertType.CityConquered -> {
|
||||
addGoodSizedLabel("What would you like to do with the city?").row()
|
||||
add(getCloseButton("Annex")).row()
|
||||
add(TextButton("Raze",skin).onClick {
|
||||
worldScreen.currentPlayerCiv.cities.first { it.name==popupAlert.value }.isBeingRazed=true
|
||||
worldScreen.shouldUpdate=true
|
||||
close()
|
||||
})
|
||||
}
|
||||
}
|
||||
open()
|
||||
isOpen = true
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
|
@ -27,6 +28,7 @@ open class PopupTable(val screen: CameraStageBaseScreen): Table(CameraStageBaseS
|
|||
fun addGoodSizedLabel(text: String): Cell<Label> {
|
||||
val label = text.toLabel()
|
||||
label.setWrap(true)
|
||||
label.setAlignment(Align.center)
|
||||
return add(label).width(screen.stage.width/2)
|
||||
}
|
||||
|
||||
|
@ -43,7 +45,6 @@ class YesNoPopupTable(question:String, action:()->Unit,
|
|||
if(!screen.hasPopupOpen) {
|
||||
screen.hasPopupOpen=true
|
||||
add(question.toLabel()).colspan(2).row()
|
||||
|
||||
add(TextButton("No".tr(), skin).onClick { close() })
|
||||
add(TextButton("Yes".tr(), skin).onClick { close(); action() })
|
||||
open()
|
||||
|
|
Loading…
Reference in a new issue