Making SpecialistAllocationTable an ExpanderTab (#6614)

* Make SpecialistAllocationTable an ExpanderTab

* Make Specialist ExpanderTab translatable
This commit is contained in:
ultradian 2022-04-26 20:14:19 -10:00 committed by GitHub
parent cf761f4a2c
commit d2f0e32229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -46,10 +46,8 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
innerTable.addSeparator()
addText()
if (!cityInfo.population.getMaxSpecialists().isEmpty()) {
innerTable.addSeparator()
innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() }).row()
addSpecialistInfo()
}
if (cityInfo.religion.getNumberOfFollowers().isNotEmpty() && cityInfo.civInfo.gameInfo.isReligionEnabled())
addReligionInfo()
@ -113,6 +111,18 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
innerTable.add(tableWithIcons).row()
}
private fun addSpecialistInfo() {
val expanderTab = SpecialistAllocationTable(cityScreen).asExpander {
pack()
setPosition(
stage.width - CityScreen.posFromEdge,
stage.height - CityScreen.posFromEdge,
Align.topRight
)
}
innerTable.add(expanderTab).growX().row()
}
private fun addReligionInfo() {
val expanderTab = CityReligionInfoTable(cityInfo.religion).asExpander {
pack()

View File

@ -86,4 +86,19 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(BaseScreen.sk
}
return specialistStatTable
}
fun asExpander(onChange: (()->Unit)?): ExpanderTab {
return ExpanderTab(
title = "{Specialists}:",
fontSize = Constants.defaultFontSize,
persistenceID = "CityStatsTable.Specialists",
startsOutOpened = true,
onChange = onChange
) {
it.add(this)
update()
}
}
}