diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index d3a4e540..a8a52827 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -847,7 +847,6 @@ Armor = City = Missile = WaterAircraftCarrier = -WaterMissileCarrier = # Units diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index e3121744..537cbb5a 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -11,6 +11,7 @@ interface IConstruction : INamed { fun isBuildable(construction: CityConstructions): Boolean fun shouldBeDisplayed(construction: CityConstructions): Boolean fun postBuildEvent(construction: CityConstructions, wasBought: Boolean = false): Boolean // Yes I'm hilarious. + fun getResource(): String? fun canBePurchased(): Boolean } @@ -65,4 +66,6 @@ open class PerpetualConstruction(override var name: String, val description: Str throw Exception("Impossible!") } + override fun getResource(): String? =null + } \ No newline at end of file diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 01dd5256..8d51ae12 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -397,6 +397,8 @@ class Building : NamedStats(), IConstruction{ return true } + override fun getResource(): String? = requiredResource + fun isStatRelated(stat: Stat): Boolean { if (get(stat) > 0) return true if (getStatPercentageBonuses(null).get(stat)>0) return true diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 6152bd3e..17cf07a3 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -172,6 +172,8 @@ class BaseUnit : INamed, IConstruction { return true } + override fun getResource(): String? = requiredResource + fun getDirectUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{ return civInfo.getEquivalentUnit(upgradesTo!!) } diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index d7e5969c..466a8b60 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -11,6 +11,7 @@ import com.unciv.logic.city.CityInfo import com.unciv.logic.city.IConstruction import com.unciv.logic.city.PerpetualConstruction import com.unciv.models.UncivSound +import com.unciv.models.ruleset.Building import com.unciv.models.stats.Stat import com.unciv.models.translations.tr import com.unciv.ui.cityscreen.ConstructionInfoTable.Companion.turnOrTurns @@ -133,16 +134,23 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre for (unit in city.getRuleset().units.values.filter { it.shouldBeDisplayed(cityConstructions) }) { val useStoredProduction = !cityConstructions.isBeingConstructedOrEnqueued(unit.name) val turnsToUnit = cityConstructions.turnsToConstruction(unit.name, useStoredProduction) - val productionButton = getProductionButton(unit.name, - unit.name.tr() + turnOrTurns(turnsToUnit), + var buttonText = unit.name.tr() + turnOrTurns(turnsToUnit) + if(unit.requiredResource != null) + buttonText += "\n"+"Consumes 1 [${unit.requiredResource}]".tr() + + val productionButton = getProductionButton(unit, + buttonText, unit.getRejectionReason(cityConstructions)) units.add(productionButton) } for (building in city.getRuleset().buildings.values.filter { it.shouldBeDisplayed(cityConstructions)}) { val turnsToBuilding = cityConstructions.turnsToConstruction(building.name) - val productionTextButton = getProductionButton(building.name, - building.name.tr() + turnOrTurns(turnsToBuilding), + var buttonText = building.name.tr() + turnOrTurns(turnsToBuilding) + if(building.requiredResource != null) + buttonText += "\n"+"Consumes 1 [${building.requiredResource}]".tr() + val productionTextButton = getProductionButton(building, + buttonText, building.getRejectionReason(cityConstructions) ) if (building.isWonder) buildableWonders += productionTextButton @@ -152,7 +160,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre for (specialConstruction in PerpetualConstruction.perpetualConstructionsMap.values .filter { it.shouldBeDisplayed(cityConstructions) }) { - specialConstructions += getProductionButton(specialConstruction.name, + specialConstructions += getProductionButton(specialConstruction, "Produce [${specialConstruction.name}]".tr() + specialConstruction.getProductionTooltip(city)) } @@ -177,7 +185,12 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre val isFirstConstructionOfItsKind = cityConstructions.isFirstConstructionOfItsKind(constructionQueueIndex, name) val turnsToComplete = cityConstructions.turnsToConstruction(name, isFirstConstructionOfItsKind) - val text = name.tr() + turnOrTurns(turnsToComplete) + var text = name.tr() + turnOrTurns(turnsToComplete) + + val constructionResource = cityConstructions.getConstruction(name).getResource() + + if(constructionResource != null) + text += "\n"+"Consumes 1 [$constructionResource]".tr() table.defaults().pad(2f).minWidth(40f) if(isFirstConstructionOfItsKind) table.add(getProgressBar(name)).minWidth(5f) @@ -212,30 +225,29 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre Color.BROWN.cpy().lerp(Color.WHITE, 0.5f), Color.WHITE) } - private fun getProductionButton(construction: String, buttonText: String, rejectionReason: String = ""): Table { + private fun getProductionButton(construction: IConstruction, buttonText: String, rejectionReason: String = ""): Table { val pickProductionButton = Table() pickProductionButton.align(Align.left).pad(5f) pickProductionButton.background = ImageGetter.getBackground(Color.BLACK) pickProductionButton.touchable = Touchable.enabled - if (!isSelectedQueueEntry() && cityScreen.selectedConstruction != null && cityScreen.selectedConstruction!!.name == construction) { + if (!isSelectedQueueEntry() && cityScreen.selectedConstruction != null && cityScreen.selectedConstruction == construction) { pickProductionButton.background = ImageGetter.getBackground(Color.GREEN.cpy().lerp(Color.BLACK, 0.5f)) } - pickProductionButton.add(getProgressBar(construction)).padRight(5f) - pickProductionButton.add(ImageGetter.getConstructionImage(construction).surroundWithCircle(40f)).padRight(10f) - pickProductionButton.add(buttonText.toLabel()).expandX().fillX().left() + pickProductionButton.add(getProgressBar(construction.name)).padRight(5f) + pickProductionButton.add(ImageGetter.getConstructionImage(construction.name).surroundWithCircle(40f)).padRight(10f) + pickProductionButton.add(buttonText.toLabel()).expandX().fillX().left().row() // no rejection reason means we can build it! if(rejectionReason != "") { pickProductionButton.color = Color.GRAY - pickProductionButton.row() pickProductionButton.add(rejectionReason.toLabel(Color.RED).apply{ setWrap(true)} ) .colspan(pickProductionButton.columns).fillX().left().padTop(2f) } pickProductionButton.onClick { - cityScreen.selectedConstruction = cityScreen.city.cityConstructions.getConstruction(construction) + cityScreen.selectedConstruction = construction cityScreen.selectedTile = null selectedQueueEntry = -2 cityScreen.update() @@ -243,6 +255,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre return pickProductionButton } + private fun isSelectedQueueEntry(): Boolean = selectedQueueEntry > -2 private fun isSelectedCurrentConstruction(): Boolean = selectedQueueEntry == -1