mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Fix wrapping for promotions in unit overview (#9239)
This commit is contained in:
@ -34,7 +34,6 @@ import com.unciv.ui.screens.pickerscreens.PromotionPickerScreen
|
|||||||
import com.unciv.ui.screens.pickerscreens.UnitRenamePopup
|
import com.unciv.ui.screens.pickerscreens.UnitRenamePopup
|
||||||
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsUpgrade
|
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsUpgrade
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.ceil
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supplies the Unit sub-table for the Empire Overview
|
* Supplies the Unit sub-table for the Empire Overview
|
||||||
@ -235,13 +234,14 @@ class UnitOverviewTab(
|
|||||||
// getPromotions goes by json order on demand, so this is same sorting as on picker
|
// getPromotions goes by json order on demand, so this is same sorting as on picker
|
||||||
val promotions = unit.promotions.getPromotions(true)
|
val promotions = unit.promotions.getPromotions(true)
|
||||||
if (promotions.any()) {
|
if (promotions.any()) {
|
||||||
val numberOfLines = ceil(promotions.count() / 8f).toInt()
|
val iconCount = promotions.count() + (if (unit.promotions.canBePromoted()) 1 else 0)
|
||||||
val promotionsPerLine = promotions.count() / numberOfLines
|
val numberOfLines = (iconCount - 1) / 8 + 1
|
||||||
var promotionsThisLine = 0
|
val promotionsPerLine = (iconCount - 1) / numberOfLines + 1
|
||||||
for (promotion in promotions) {
|
for (linePromotions in promotions.chunked(promotionsPerLine)) {
|
||||||
promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name))
|
for (promotion in linePromotions) {
|
||||||
promotionsThisLine++
|
promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name))
|
||||||
if (promotionsThisLine == promotionsPerLine && numberOfLines>1) promotionsTable.row()
|
}
|
||||||
|
if (linePromotions.size == promotionsPerLine) promotionsTable.row()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user