Fixed queue showing "Consumes 1" when no resource is consumed

Plus linting
This commit is contained in:
Yair Morgenstern 2021-02-07 19:13:10 +02:00
parent 5328efa233
commit 7d9b56e3b1
6 changed files with 29 additions and 32 deletions

View File

@ -39,7 +39,8 @@ open class TileInfo {
// This will be called often - farm can be built on Hill and tundra if adjacent to fresh water
// and farms on adjacent to fresh water tiles will have +1 additional Food after researching Civil Service
@delegate:Transient
val isAdjacentToFreshwater: Boolean by lazy { matchesUniqueFilter("River") || matchesUniqueFilter("Fresh water") || neighbors.any { it.matchesUniqueFilter("Fresh water") } }
val isAdjacentToFreshwater: Boolean by lazy { matchesUniqueFilter("River") || matchesUniqueFilter("Fresh water")
|| neighbors.any { it.matchesUniqueFilter("Fresh water") } }
var militaryUnit: MapUnit? = null
var civilianUnit: MapUnit? = null

View File

@ -181,8 +181,8 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
for ((key, value) in cityStats.baseStatList)
relevantBaseStats[key] = value.get(stat)
else relevantBaseStats.putAll(cityStats.happinessList)
for(key in relevantBaseStats.keys.toList())
if(relevantBaseStats[key]==0f) relevantBaseStats.remove(key)
for (key in relevantBaseStats.keys.toList())
if (relevantBaseStats[key] == 0f) relevantBaseStats.remove(key)
if (relevantBaseStats.isEmpty()) continue
@ -220,7 +220,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
else statValuesTable.add("$decimal%".toLabel()).row() // negative bonus
}
if(stat!=Stat.Happiness) {
if (stat != Stat.Happiness) {
statValuesTable.add("Final".toLabel(fontSize = FONT_SIZE_STAT_INFO_HEADER)).colspan(2).padTop(20f).row()
var finalTotal = 0f
for (entry in cityStats.finalStatList) {

View File

@ -7,7 +7,7 @@ import com.badlogic.gdx.utils.Align
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table() {
fun update() {
val city = cityScreen.city
@ -25,18 +25,18 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
} else add()
val cityNameTable = Table()
if(city.isBeingRazed){
if (city.isBeingRazed) {
val fireImage = ImageGetter.getImage("OtherIcons/Fire")
cityNameTable.add(fireImage).size(20f).padRight(5f)
}
if(city.isCapital()){
val starImage = ImageGetter.getImage("OtherIcons/Star").apply { color= Color.LIGHT_GRAY }
if (city.isCapital()) {
val starImage = ImageGetter.getImage("OtherIcons/Star").apply { color = Color.LIGHT_GRAY }
cityNameTable.add(starImage).size(20f).padRight(5f)
}
if(city.isPuppet){
val starImage = ImageGetter.getImage("OtherIcons/Puppet").apply { color= Color.LIGHT_GRAY }
if (city.isPuppet) {
val starImage = ImageGetter.getImage("OtherIcons/Puppet").apply { color = Color.LIGHT_GRAY }
cityNameTable.add(starImage).size(20f).padRight(5f)
}
@ -53,7 +53,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
textArea.alignment = Align.center
editCityNamePopup.add(textArea).colspan(2).row()
editCityNamePopup.addCloseButton()
editCityNamePopup.addButton("Save".tr()){
editCityNamePopup.addButton("Save".tr()) {
city.name = textArea.text
cityScreen.game.setScreen(CityScreen(city))
}
@ -62,14 +62,14 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
cityNameTable.add(currentCityLabel)
add(cityNameTable).width(stage.width/4)
add(cityNameTable).width(stage.width / 4)
if (civInfo.cities.size > 1) {
val nextCityButton = Table() // so we gt a wider clickable area than just the image itself
val image = ImageGetter.getImage("OtherIcons/BackArrow")
image.setSize(25f,25f)
image.setSize(25f, 25f)
image.setOrigin(Align.center)
image.rotation = 180f
image.color = civInfo.nation.getInnerColor()
@ -80,4 +80,4 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
pack()
}
}
}

View File

@ -40,7 +40,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
baseLayerGroup.color.a = 0.5f
}
tileInfo.isWorked() && tileInfo.getWorkingCity()!=city -> {
tileInfo.isWorked() && tileInfo.getWorkingCity() != city -> {
// Don't fade out, but don't add a population icon either.
baseLayerGroup.color.a = 0.5f
}
@ -72,13 +72,12 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
yieldGroup.setScale(0.7f)
yieldGroup.toFront()
yieldGroup.centerX(this)
yieldGroup.y= height * 0.25f - yieldGroup.height / 2
yieldGroup.y = height * 0.25f - yieldGroup.height / 2
if (tileInfo.isWorked()) {
yieldGroup.color = Color.WHITE
}
else if(!tileInfo.isCityCenter()){
yieldGroup.color = Color.GRAY.cpy().apply { a=0.5f }
} else if (!tileInfo.isCityCenter()) {
yieldGroup.color = Color.GRAY.cpy().apply { a = 0.5f }
}
}
@ -89,12 +88,8 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
populationIcon.setPosition(width / 2 - populationIcon.width / 2,
height * 0.85f - populationIcon.height / 2)
if (tileInfo.isWorked()) {
populationIcon.color = Color.WHITE
}
else if(!tileInfo.isCityCenter()){
populationIcon.color = Color.GRAY.cpy()
}
if (tileInfo.isWorked()) populationIcon.color = Color.WHITE
else if (!tileInfo.isCityCenter()) populationIcon.color = Color.GRAY.cpy()
populationIcon.toFront()
}

View File

@ -16,7 +16,8 @@ import com.unciv.ui.utils.AutoScrollPane as ScrollPane
class ConstructionInfoTable(val city: CityInfo): Table() {
val selectedConstructionTable = Table()
init{
init {
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
add(selectedConstructionTable).pad(2f).fill()
background = ImageGetter.getBackground(Color.WHITE)
@ -41,7 +42,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
val cityConstructions = city.cityConstructions
//val selectedConstructionTable = Table()
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK,0.5f))
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
selectedConstructionTable.pad(10f)
selectedConstructionTable.add(
@ -55,8 +56,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
val turnsToComplete = cityConstructions.turnsToConstruction(construction.name)
buildingText += ("\r\n" + "Cost".tr() + " " + construction.getProductionCost(city.civInfo).toString()).tr()
buildingText += turnOrTurns(turnsToComplete)
}
else {
} else {
buildingText += specialConstruction.getProductionTooltip(city)
}
selectedConstructionTable.add(buildingText.toLabel()).row()
@ -65,7 +65,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
val description: String = when (construction) {
is BaseUnit -> construction.getDescription(true)
is Building -> construction.getDescription(true, city.civInfo, city.civInfo.gameInfo.ruleSet)
is PerpetualConstruction -> construction.description.replace("[rate]","[${construction.getConversionRate(city)}]") .tr()
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]").tr()
else -> "" // Should never happen
}

View File

@ -228,9 +228,10 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
else turnOrTurns(turnsToComplete)
val constructionResource = cityConstructions.getConstruction(name).getResourceRequirements()
for ((resource, amount) in constructionResource)
if (amount == 1) text += "\n" + "Consumes 1 [$resource]".tr()
else text += "\n" + "Consumes [$amount] [$resource]".tr()
if (constructionResource != null)
text += "\n" + "Consumes 1 [$constructionResource]".tr()
table.defaults().pad(2f).minWidth(40f)
if (isFirstConstructionOfItsKind) table.add(getProgressBar(name)).minWidth(5f)