mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Tech picker screen auto-handles eras of different lengths
This commit is contained in:
parent
45d90c0458
commit
8d3b0b09e9
@ -14,6 +14,7 @@ import com.unciv.models.ruleset.tech.Technology
|
|||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
|
||||||
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null) : PickerScreen() {
|
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null) : PickerScreen() {
|
||||||
@ -99,11 +100,19 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
||||||
}
|
}
|
||||||
|
|
||||||
val erasName = allTechs.map { it.era() }.distinct()
|
val erasNamesToColumns = LinkedHashMap<String, ArrayList<Int>>()
|
||||||
for ((i, eraName) in erasName.withIndex()) {
|
for(tech in allTechs) {
|
||||||
val columnSpan = if (eraName != Constants.ancientEra && eraName != Constants.futureEra) 2 else 3
|
val era = tech.era()
|
||||||
|
if (!erasNamesToColumns.containsKey(era)) erasNamesToColumns[era] = ArrayList()
|
||||||
|
val columnNumber = tech.column!!.columnNumber
|
||||||
|
if (!erasNamesToColumns[era]!!.contains(columnNumber)) erasNamesToColumns[era]!!.add(columnNumber)
|
||||||
|
}
|
||||||
|
var i=0
|
||||||
|
for ((era, columns) in erasNamesToColumns) {
|
||||||
|
val columnSpan = columns.size
|
||||||
val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK
|
val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK
|
||||||
techTable.add(eraName.toLabel().addBorder(2f, color)).fill().colspan(columnSpan)
|
i++
|
||||||
|
techTable.add(era.toLabel().addBorder(2f, color)).fill().colspan(columnSpan)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 0..9) {
|
for (i in 0..9) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user