Game can handle the situation where there are no more techs that can be researched (in mods with limited techs)

This commit is contained in:
Yair Morgenstern 2020-08-17 23:17:49 +03:00
parent 2c8074bfe4
commit 1abbd1520c
2 changed files with 11 additions and 13 deletions

View File

@ -225,7 +225,7 @@ class CivilizationInfo {
//endregion
fun shouldOpenTechPicker(): Boolean {
if (gameInfo.ruleSet.technologies.isEmpty()) return false
if (!tech.canResearchTech()) return false
if (tech.freeTechs != 0) return true
return tech.currentTechnology() == null && cities.isNotEmpty()
}

View File

@ -435,27 +435,25 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
}
private fun updateTechButton() {
if(gameInfo.ruleSet.technologies.isEmpty()) return
if (gameInfo.ruleSet.technologies.isEmpty()) return
techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty()
techButtonHolder.clearChildren()
if (viewingCiv.tech.currentTechnology() == null && viewingCiv.tech.canResearchTech()) {
val buttonPic = Table()
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
buttonPic.defaults().pad(20f)
buttonPic.add("{Pick a tech}!".toLabel(Color.WHITE,30))
techButtonHolder.add(buttonPic)
}
else {
if (viewingCiv.tech.currentTechnology() != null) {
val currentTech = viewingCiv.tech.currentTechnologyName()!!
val innerButton = TechButton(currentTech,viewingCiv.tech)
val innerButton = TechButton(currentTech, viewingCiv.tech)
innerButton.color = colorFromRGB(7, 46, 43)
techButtonHolder.add(innerButton)
val turnsToTech = viewingCiv.tech.turnsToTech(currentTech)
innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech
+ (if(turnsToTech>1) " {turns}".tr() else " {turn}".tr()))
+ (if (turnsToTech > 1) " {turns}".tr() else " {turn}".tr()))
} else if (viewingCiv.tech.canResearchTech()) {
val buttonPic = Table()
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
buttonPic.defaults().pad(20f)
buttonPic.add("{Pick a tech}!".toLabel(Color.WHITE, 30))
techButtonHolder.add(buttonPic)
}
techButtonHolder.pack() //setSize(techButtonHolder.prefWidth, techButtonHolder.prefHeight)
}