mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:14:25 +07:00
perf (ANR): Only parse and sort civs in global politics table once
This commit is contained in:
parent
5e6a3e0f67
commit
b0bf22e6d1
@ -66,8 +66,8 @@ class GlobalPoliticsOverviewTable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reusable sequences for the Civilizations to display
|
// Reusable sequences for the Civilizations to display
|
||||||
private var undefeatedCivs = sequenceOf<Civilization>()
|
private var undefeatedCivs = listOf<Civilization>()
|
||||||
private var defeatedCivs = sequenceOf<Civilization>()
|
private var defeatedCivs = listOf<Civilization>()
|
||||||
|
|
||||||
private var relevantCivsCount = "?" // includes unknown civs if player allowed to know
|
private var relevantCivsCount = "?" // includes unknown civs if player allowed to know
|
||||||
private var showDiplomacyGroup = false
|
private var showDiplomacyGroup = false
|
||||||
@ -292,10 +292,10 @@ class GlobalPoliticsOverviewTable(
|
|||||||
else gameInfo.civilizations.count {
|
else gameInfo.civilizations.count {
|
||||||
!it.isSpectator() && !it.isBarbarian && (persistableData.includeCityStates || !it.isCityState)
|
!it.isSpectator() && !it.isBarbarian && (persistableData.includeCityStates || !it.isCityState)
|
||||||
}.tr()
|
}.tr()
|
||||||
undefeatedCivs = sequenceOf(viewingPlayer) +
|
undefeatedCivs = listOf(viewingPlayer) +
|
||||||
viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates)
|
viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates)
|
||||||
defeatedCivs = viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates, true)
|
defeatedCivs = viewingPlayer.diplomacyFunctions.getKnownCivsSorted(persistableData.includeCityStates, true)
|
||||||
.filter { it.isDefeated() }
|
.filter { it.isDefeated() }.toList()
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
fixedContent.clear()
|
fixedContent.clear()
|
||||||
@ -373,7 +373,7 @@ class GlobalPoliticsOverviewTable(
|
|||||||
add("Turns until the next\ndiplomacy victory vote: [$turnsTillNextDiplomaticVote]".toLabel()).colspan(columns).row()
|
add("Turns until the next\ndiplomacy victory vote: [$turnsTillNextDiplomaticVote]".toLabel()).colspan(columns).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Table.addCivsCategory(columns: Int, aliveOrDefeated: String, civs: Sequence<Civilization>) {
|
private fun Table.addCivsCategory(columns: Int, aliveOrDefeated: String, civs: List<Civilization>) {
|
||||||
addSeparator()
|
addSeparator()
|
||||||
val count = civs.count()
|
val count = civs.count()
|
||||||
add("Known and $aliveOrDefeated ([$count])".toLabel())
|
add("Known and $aliveOrDefeated ([$count])".toLabel())
|
||||||
@ -410,7 +410,7 @@ class GlobalPoliticsOverviewTable(
|
|||||||
* @param freeSize Width and height this [Group] sizes itself to
|
* @param freeSize Width and height this [Group] sizes itself to
|
||||||
*/
|
*/
|
||||||
private class DiplomacyGroup(
|
private class DiplomacyGroup(
|
||||||
undefeatedCivs: Sequence<Civilization>,
|
undefeatedCivs: List<Civilization>,
|
||||||
freeSize: Float
|
freeSize: Float
|
||||||
): Group() {
|
): Group() {
|
||||||
private fun onCivClicked(civLines: HashMap<String, MutableSet<Actor>>, name: String) {
|
private fun onCivClicked(civLines: HashMap<String, MutableSet<Actor>>, name: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user