mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Unified construction button metadata / UI split
This commit is contained in:
parent
ab262da205
commit
6c66600fce
@ -10,6 +10,8 @@ import com.unciv.logic.city.CityInfo
|
|||||||
import com.unciv.logic.city.IConstruction
|
import com.unciv.logic.city.IConstruction
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
import com.unciv.models.UncivSound
|
import com.unciv.models.UncivSound
|
||||||
|
import com.unciv.models.ruleset.Building
|
||||||
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.cityscreen.ConstructionInfoTable.Companion.turnOrTurns
|
import com.unciv.ui.cityscreen.ConstructionInfoTable.Companion.turnOrTurns
|
||||||
@ -123,16 +125,12 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
constructionsQueueTable.add("Queue empty".toLabel()).pad(2f).row()
|
constructionsQueueTable.add("Queue empty".toLabel()).pad(2f).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAvailableConstructions() {
|
private fun getConstructionButtonDTOs():ArrayList<ConstructionButtonDTO> {
|
||||||
|
val constructionButtonDTOList = ArrayList<ConstructionButtonDTO>()
|
||||||
|
|
||||||
val city = cityScreen.city
|
val city = cityScreen.city
|
||||||
val cityConstructions = city.cityConstructions
|
val cityConstructions = city.cityConstructions
|
||||||
|
|
||||||
val units = ArrayList<Table>()
|
|
||||||
val buildableWonders = ArrayList<Table>()
|
|
||||||
val buildableNationalWonders = ArrayList<Table>()
|
|
||||||
val buildableBuildings = ArrayList<Table>()
|
|
||||||
val specialConstructions = ArrayList<Table>()
|
|
||||||
|
|
||||||
for (unit in city.getRuleset().units.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
for (unit in city.getRuleset().units.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||||
val useStoredProduction = !cityConstructions.isBeingConstructedOrEnqueued(unit.name)
|
val useStoredProduction = !cityConstructions.isBeingConstructedOrEnqueued(unit.name)
|
||||||
val turnsToUnit = cityConstructions.turnsToConstruction(unit.name, useStoredProduction)
|
val turnsToUnit = cityConstructions.turnsToConstruction(unit.name, useStoredProduction)
|
||||||
@ -140,35 +138,58 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
if (unit.requiredResource != null)
|
if (unit.requiredResource != null)
|
||||||
buttonText += "\n" + "Consumes 1 [${unit.requiredResource}]".tr()
|
buttonText += "\n" + "Consumes 1 [${unit.requiredResource}]".tr()
|
||||||
|
|
||||||
val productionButton = getConstructionButton(ConstructionButtonDTO(unit,
|
constructionButtonDTOList.add(ConstructionButtonDTO(unit,
|
||||||
buttonText,
|
buttonText,
|
||||||
unit.getRejectionReason(cityConstructions)))
|
unit.getRejectionReason(cityConstructions)))
|
||||||
units.add(productionButton)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (building in city.getRuleset().buildings.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
for (building in city.getRuleset().buildings.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||||
val turnsToBuilding = cityConstructions.turnsToConstruction(building.name)
|
val turnsToBuilding = cityConstructions.turnsToConstruction(building.name)
|
||||||
var buttonText = building.name.tr() + turnOrTurns(turnsToBuilding)
|
var buttonText = building.name.tr() + turnOrTurns(turnsToBuilding)
|
||||||
if (building.requiredResource != null)
|
if (building.requiredResource != null)
|
||||||
buttonText += "\n" + "Consumes 1 [${building.requiredResource}]".tr()
|
buttonText += "\n" + "Consumes 1 [${building.requiredResource}]".tr()
|
||||||
val productionTextButton = getConstructionButton(ConstructionButtonDTO(building,
|
|
||||||
|
constructionButtonDTOList.add(ConstructionButtonDTO(building,
|
||||||
buttonText,
|
buttonText,
|
||||||
building.getRejectionReason(cityConstructions)
|
building.getRejectionReason(cityConstructions)
|
||||||
))
|
))
|
||||||
when {
|
|
||||||
building.isWonder -> buildableWonders += productionTextButton
|
|
||||||
building.isNationalWonder -> buildableNationalWonders += productionTextButton
|
|
||||||
else -> buildableBuildings += productionTextButton
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (specialConstruction in PerpetualConstruction.perpetualConstructionsMap.values
|
for (specialConstruction in PerpetualConstruction.perpetualConstructionsMap.values
|
||||||
.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||||
specialConstructions += getConstructionButton(ConstructionButtonDTO(specialConstruction,
|
constructionButtonDTOList.add(ConstructionButtonDTO(specialConstruction,
|
||||||
"Produce [${specialConstruction.name}]".tr()
|
"Produce [${specialConstruction.name}]".tr()
|
||||||
+ specialConstruction.getProductionTooltip(city)))
|
+ specialConstruction.getProductionTooltip(city)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return constructionButtonDTOList
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateAvailableConstructions() {
|
||||||
|
val units = ArrayList<Table>()
|
||||||
|
val buildableWonders = ArrayList<Table>()
|
||||||
|
val buildableNationalWonders = ArrayList<Table>()
|
||||||
|
val buildableBuildings = ArrayList<Table>()
|
||||||
|
val specialConstructions = ArrayList<Table>()
|
||||||
|
|
||||||
|
val constructionButtonDTOList = getConstructionButtonDTOs()
|
||||||
|
|
||||||
|
for(dto in constructionButtonDTOList) {
|
||||||
|
val constructionButton = getConstructionButton(dto)
|
||||||
|
when (dto.construction) {
|
||||||
|
is BaseUnit -> units.add(constructionButton)
|
||||||
|
is Building -> {
|
||||||
|
when {
|
||||||
|
dto.construction.isWonder -> buildableWonders += constructionButton
|
||||||
|
dto.construction.isNationalWonder -> buildableNationalWonders += constructionButton
|
||||||
|
else -> buildableBuildings += constructionButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is PerpetualConstruction -> specialConstructions.add(constructionButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
availableConstructionsTable.addCategory("Units", units, constructionsQueueTable.width)
|
availableConstructionsTable.addCategory("Units", units, constructionsQueueTable.width)
|
||||||
availableConstructionsTable.addCategory("Wonders", buildableWonders, constructionsQueueTable.width)
|
availableConstructionsTable.addCategory("Wonders", buildableWonders, constructionsQueueTable.width)
|
||||||
availableConstructionsTable.addCategory("National Wonders", buildableNationalWonders, constructionsQueueTable.width)
|
availableConstructionsTable.addCategory("National Wonders", buildableNationalWonders, constructionsQueueTable.width)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user