Added progress bars for constructions in city screen

This commit is contained in:
Yair Morgenstern
2020-03-25 14:51:18 +02:00
parent ac34b8f5ff
commit 44b69d2d87
2 changed files with 16 additions and 1 deletions

View File

@ -180,6 +180,8 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
val text = name.tr() + turnOrTurns(turnsToComplete)
table.defaults().pad(2f).minWidth(40f)
if(isFirstConstructionOfItsKind) table.add(getProgressBar(name)).minWidth(5f)
else table.add().minWidth(5f)
table.add(ImageGetter.getConstructionImage(name).surroundWithCircle(40f)).padRight(10f)
table.add(text.toLabel()).expandX().fillX().left()
@ -198,6 +200,18 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
return table
}
fun getProgressBar(constructionName:String): Table {
val cityConstructions = cityScreen.city.cityConstructions
val construction = cityConstructions.getConstruction(constructionName)
if (construction is PerpetualConstruction) return Table()
if (cityConstructions.getWorkDone(constructionName) == 0) return Table()
val constructionPercentage = cityConstructions.getWorkDone(constructionName) /
construction.getProductionCost(cityConstructions.cityInfo.civInfo).toFloat()
return ImageGetter.getProgressBarVertical(2f, 30f, constructionPercentage,
Color.BROWN.cpy().lerp(Color.WHITE, 0.5f), Color.WHITE)
}
private fun getProductionButton(construction: String, buttonText: String, rejectionReason: String = ""): Table {
val pickProductionButton = Table()
@ -209,6 +223,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
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()

View File

@ -250,7 +250,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
image.centerY(group)
image.x = group.width-image.width
// center the circle on thee production image
// center the circle on the production image
circle.x = image.x + (image.width-circle.width)/2
circle.y = image.y + (image.height-circle.height)/2