mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
Can now create as many tech rows as you wish in mods :)
This commit is contained in:
@ -93,21 +93,22 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
|
|
||||||
private fun createTechTable() {
|
private fun createTechTable() {
|
||||||
val allTechs = civInfo.gameInfo.ruleSet.technologies.values
|
val allTechs = civInfo.gameInfo.ruleSet.technologies.values
|
||||||
val columns = allTechs.map { it.column!!.columnNumber }.max()!! + 1
|
val columns = allTechs.map { it.column!!.columnNumber }.maxOrNull()!! + 1
|
||||||
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
|
val rows = allTechs.map { it.row }.maxOrNull()!! + 1
|
||||||
|
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(rows) } // Divided into columns, then rows
|
||||||
|
|
||||||
for (technology in allTechs) {
|
for (technology in allTechs) {
|
||||||
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
||||||
}
|
}
|
||||||
|
|
||||||
val erasNamesToColumns = LinkedHashMap<String, ArrayList<Int>>()
|
val erasNamesToColumns = LinkedHashMap<String, ArrayList<Int>>()
|
||||||
for(tech in allTechs) {
|
for (tech in allTechs) {
|
||||||
val era = tech.era()
|
val era = tech.era()
|
||||||
if (!erasNamesToColumns.containsKey(era)) erasNamesToColumns[era] = ArrayList()
|
if (!erasNamesToColumns.containsKey(era)) erasNamesToColumns[era] = ArrayList()
|
||||||
val columnNumber = tech.column!!.columnNumber
|
val columnNumber = tech.column!!.columnNumber
|
||||||
if (!erasNamesToColumns[era]!!.contains(columnNumber)) erasNamesToColumns[era]!!.add(columnNumber)
|
if (!erasNamesToColumns[era]!!.contains(columnNumber)) erasNamesToColumns[era]!!.add(columnNumber)
|
||||||
}
|
}
|
||||||
var i=0
|
var i = 0
|
||||||
for ((era, columns) in erasNamesToColumns) {
|
for ((era, columns) in erasNamesToColumns) {
|
||||||
val columnSpan = columns.size
|
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
|
||||||
@ -283,4 +284,4 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user