mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 14:48:56 +07:00
Some modifications for performance optimization (#8631)
This commit is contained in:
@ -20,11 +20,11 @@ open class Counter<K> : LinkedHashMap<K, Int>(), IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun add(other: Counter<K>) {
|
||||
for (key in other.keys) add(key, other[key]!!)
|
||||
for ((key, value) in other) add(key, value)
|
||||
}
|
||||
|
||||
fun remove(other: Counter<K>) {
|
||||
for (key in other.keys) add(key, -other[key]!!)
|
||||
for ((key, value) in other) add(key, -value)
|
||||
}
|
||||
|
||||
fun times(amount:Int): Counter<K> {
|
||||
|
@ -41,8 +41,8 @@ class TechPickerScreen(
|
||||
private var selectedTech: Technology? = null
|
||||
private var civTech: TechManager = civInfo.tech
|
||||
private var tempTechsToResearch: ArrayList<String>
|
||||
private var lines = ArrayList<Image>()
|
||||
private var orderIndicators = Group()
|
||||
private var lines = Group().apply { isTransform = false }
|
||||
private var orderIndicators = Group().apply { isTransform = false }
|
||||
private var eraLabels = ArrayList<Label>()
|
||||
|
||||
/** We need this to be a separate table, and NOT the topTable, because *inhales*
|
||||
@ -79,6 +79,8 @@ class TechPickerScreen(
|
||||
|
||||
createTechTable()
|
||||
setButtonsInfo()
|
||||
techTable.addActor(lines)
|
||||
techTable.addActor(orderIndicators)
|
||||
topTable.add(techTable)
|
||||
techTable.background = skinStrings.getUiBackground("TechPickerScreen/Background", tintColor = skinStrings.skinConfig.clearColor)
|
||||
pickerPane.bottomTable.background = skinStrings.getUiBackground("TechPickerScreen/BottomTable", tintColor = skinStrings.skinConfig.clearColor)
|
||||
@ -231,7 +233,6 @@ class TechPickerScreen(
|
||||
techTable.pack() // required for the table to have the button positions set, so topTable.stageToLocalCoordinates will be correct
|
||||
scrollPane.updateVisualScroll()
|
||||
|
||||
for (line in lines) line.remove()
|
||||
lines.clear()
|
||||
|
||||
for (eraLabel in eraLabels) {
|
||||
@ -241,8 +242,7 @@ class TechPickerScreen(
|
||||
val line = ImageGetter.getLine(coords.x-1f, coords.y, coords.x-1f, coords.y - 1000f, 1f)
|
||||
line.color = Color.GRAY.cpy().apply { a = 0.6f }
|
||||
line.toBack()
|
||||
techTable.addActor(line)
|
||||
lines.add(line)
|
||||
lines.addActor(line)
|
||||
}
|
||||
|
||||
for (tech in civInfo.gameInfo.ruleset.technologies.values) {
|
||||
@ -321,23 +321,11 @@ class TechPickerScreen(
|
||||
line3.color = lineColor
|
||||
line4.color = lineColor
|
||||
|
||||
techTable.addActor(line)
|
||||
techTable.addActor(line1)
|
||||
techTable.addActor(line2)
|
||||
techTable.addActor(line3)
|
||||
techTable.addActor(line4)
|
||||
|
||||
line.toFront()
|
||||
line1.toFront()
|
||||
line2.toFront()
|
||||
line3.toFront()
|
||||
line4.toFront()
|
||||
|
||||
lines.add(line)
|
||||
lines.add(line1)
|
||||
lines.add(line2)
|
||||
lines.add(line3)
|
||||
lines.add(line4)
|
||||
lines.addActor(line)
|
||||
lines.addActor(line1)
|
||||
lines.addActor(line2)
|
||||
lines.addActor(line3)
|
||||
lines.addActor(line4)
|
||||
|
||||
} else {
|
||||
|
||||
@ -349,23 +337,13 @@ class TechPickerScreen(
|
||||
}
|
||||
line.color = lineColor
|
||||
|
||||
techTable.addActor(line)
|
||||
|
||||
if (tempTechsToResearch.contains(tech.name))
|
||||
line.zIndex = 200000
|
||||
else
|
||||
line.zIndex = 500
|
||||
|
||||
lines.add(line)
|
||||
|
||||
lines.addActor(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (line in lines) {
|
||||
if (line.color == currentTechColor)
|
||||
line.toFront()
|
||||
}
|
||||
lines.children.filter { it.color == currentTechColor && it.color != Color.WHITE.cpy() }
|
||||
.forEach { it.toFront() }
|
||||
}
|
||||
|
||||
private fun addOrderIndicators() {
|
||||
@ -384,7 +362,6 @@ class TechPickerScreen(
|
||||
orderIndicators.addActor(orderIndicator)
|
||||
}
|
||||
}
|
||||
techTable.addActor(orderIndicators)
|
||||
orderIndicators.toFront()
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ class TranslationTests {
|
||||
fun allTranslationsHaveCorrectPlaceholders() {
|
||||
var allTranslationsHaveCorrectPlaceholders = true
|
||||
val languages = translations.getLanguages()
|
||||
for (key in translations.keys) {
|
||||
val translationEntry = translations[key]!!.entry
|
||||
for ((key, translation) in translations) {
|
||||
val translationEntry = translation.entry
|
||||
val placeholders = squareBraceRegex.findAll(translationEntry)
|
||||
.map { it.value }.toList()
|
||||
for (language in languages) {
|
||||
@ -111,9 +111,9 @@ class TranslationTests {
|
||||
@Test
|
||||
fun allPlaceholderKeysMatchEntry() {
|
||||
var allPlaceholderKeysMatchEntry = true
|
||||
for (key in translations.keys) {
|
||||
for ((key, translation) in translations) {
|
||||
if (!key.contains('[') || key.contains('<')) continue
|
||||
val translationEntry = translations[key]!!.entry
|
||||
val translationEntry = translation.entry
|
||||
val keyFromEntry = translationEntry.replace(squareBraceRegex, "[]")
|
||||
if (key != keyFromEntry) {
|
||||
allPlaceholderKeysMatchEntry = false
|
||||
|
Reference in New Issue
Block a user