Autosize of the tech buttons (#2346)
* Autosize of the tech buttons * Using minWidth parameter
This commit is contained in:
parent
e4fab26b43
commit
73aeaf6ad7
1 changed files with 11 additions and 8 deletions
|
@ -10,7 +10,7 @@ import com.unciv.ui.utils.ImageGetter
|
|||
import com.unciv.ui.utils.surroundWithCircle
|
||||
import com.unciv.ui.utils.toLabel
|
||||
|
||||
class TechButton(techName:String, val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
|
||||
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
|
||||
val text= "".toLabel().apply { setAlignment(Align.center) }
|
||||
|
||||
init {
|
||||
|
@ -40,6 +40,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
|||
private fun addTechEnabledIcons(techName: String, isWorldScreen: Boolean, rightSide: Table) {
|
||||
val techEnabledIcons = Table()
|
||||
techEnabledIcons.defaults().pad(5f)
|
||||
val techIconSize = 30f
|
||||
|
||||
val civName = techManager.civInfo.civName
|
||||
val gameBasics = techManager.civInfo.gameInfo.ruleSet
|
||||
|
@ -47,27 +48,29 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
|||
val tech = gameBasics.technologies[techName]!!
|
||||
|
||||
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(techIconSize))
|
||||
|
||||
for (building in tech.getEnabledBuildings(techManager.civInfo))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize))
|
||||
|
||||
for (improvement in gameBasics.tileImprovements.values
|
||||
.filter { it.techRequired == techName || it.improvingTech == techName }
|
||||
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
||||
if (improvement.name.startsWith("Remove"))
|
||||
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(30f)
|
||||
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
|
||||
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(techIconSize)
|
||||
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, techIconSize))
|
||||
}
|
||||
|
||||
for (resource in gameBasics.tileResources.values.filter { it.revealedBy == techName })
|
||||
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
|
||||
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, techIconSize))
|
||||
|
||||
for (unique in tech.uniques)
|
||||
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star")
|
||||
.apply { color = Color.BLACK }.surroundWithCircle(30f))
|
||||
.apply { color = Color.BLACK }.surroundWithCircle(techIconSize))
|
||||
|
||||
if (isWorldScreen) rightSide.add(techEnabledIcons)
|
||||
else rightSide.add(techEnabledIcons).width(150f)
|
||||
else rightSide.add(techEnabledIcons)
|
||||
.width(techEnabledIcons.children.size * (techIconSize+6f))
|
||||
.minWidth(150f)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue