mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-05 23:20:48 +07:00
Technology and construction bars no longer extend past their maximum (#3930)
* Technology and construction bars no longer extend past their maximum * Fixed compile errors * actually fixed the issue
This commit is contained in:
parent
abaa678e2b
commit
7b0ea32c47
@ -17,6 +17,7 @@ import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import java.lang.Float.min
|
||||
import kotlin.concurrent.thread
|
||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
|
||||
@ -258,8 +259,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
if (construction is PerpetualConstruction) return Table()
|
||||
if (cityConstructions.getWorkDone(constructionName) == 0) return Table()
|
||||
|
||||
val constructionPercentage = cityConstructions.getWorkDone(constructionName) /
|
||||
construction.getProductionCost(cityConstructions.cityInfo.civInfo).toFloat()
|
||||
val constructionPercentage = min(cityConstructions.getWorkDone(constructionName) /
|
||||
construction.getProductionCost(cityConstructions.cityInfo.civInfo).toFloat(),
|
||||
1f)
|
||||
return ImageGetter.getProgressBarVertical(2f, 30f, constructionPercentage,
|
||||
Color.BROWN.cpy().lerp(Color.WHITE, 0.5f), Color.WHITE)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.civilization.TechManager
|
||||
import com.unciv.ui.utils.*
|
||||
import java.lang.Float.min
|
||||
|
||||
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
|
||||
val text = "".toLabel().apply { setAlignment(Align.center) }
|
||||
@ -26,7 +27,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
||||
val techThisTurn = techManager.civInfo.statsForNextTurn.science
|
||||
|
||||
val percentComplete = (techCost - remainingTech) / techCost.toFloat()
|
||||
val percentWillBeComplete = (techCost - (remainingTech-techThisTurn)) / techCost.toFloat()
|
||||
val percentWillBeComplete = min((techCost - (remainingTech-techThisTurn)) / techCost.toFloat(), 1f)
|
||||
val progressBar = ImageGetter.VerticalProgressBar(2f, 50f)
|
||||
.addColor(Color.WHITE, 1f)
|
||||
.addColor(Color.BLUE.cpy().lerp(Color.WHITE, 0.3f), percentWillBeComplete)
|
||||
|
@ -366,8 +366,9 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
label.pack()
|
||||
group.addActor(label)
|
||||
|
||||
val constructionPercentage = cityConstructions.getWorkDone(cityCurrentConstruction.name) /
|
||||
cityCurrentConstruction.getProductionCost(cityConstructions.cityInfo.civInfo).toFloat()
|
||||
val constructionPercentage = min(cityConstructions.getWorkDone(cityCurrentConstruction.name) /
|
||||
cityCurrentConstruction.getProductionCost(cityConstructions.cityInfo.civInfo).toFloat(),
|
||||
1f)
|
||||
val productionBar = ImageGetter.getProgressBarVertical(2f, groupHeight, constructionPercentage,
|
||||
Color.BROWN.cpy().lerp(Color.WHITE, 0.5f), Color.BLACK)
|
||||
productionBar.x = 10f
|
||||
|
Loading…
Reference in New Issue
Block a user