mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 06:04:02 +07:00
Sort resources by name and amount (#2152)
This commit is contained in:
parent
1978d7e707
commit
a18d52c82a
@ -19,7 +19,7 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
||||
val table = Table(CameraStageBaseScreen.skin).apply { defaults().pad(5f) }
|
||||
|
||||
|
||||
val expanderTabs = HashMap<TradeType, ExpanderTab>()
|
||||
private val expanderTabs = HashMap<TradeType, ExpanderTab>()
|
||||
|
||||
fun update(offersToDisplay:TradeOffersList) {
|
||||
table.clear()
|
||||
@ -41,12 +41,13 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
||||
}
|
||||
}
|
||||
|
||||
for (offertype in values()) {
|
||||
val offersOfType = offersToDisplay.filter { it.type == offertype }
|
||||
for (offerType in values()) {
|
||||
val offersOfType = offersToDisplay.filter { it.type == offerType }.
|
||||
sortedBy { it.name }.sortedByDescending { it.amount }
|
||||
|
||||
if (expanderTabs.containsKey(offertype)) {
|
||||
expanderTabs[offertype]!!.innerTable.clear()
|
||||
table.add(expanderTabs[offertype]!!).row()
|
||||
if (expanderTabs.containsKey(offerType)) {
|
||||
expanderTabs[offerType]!!.innerTable.clear()
|
||||
table.add(expanderTabs[offerType]!!).row()
|
||||
}
|
||||
|
||||
for (offer in offersOfType) {
|
||||
@ -62,12 +63,12 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
||||
else tradeButton.disable() // for instance we have negative gold
|
||||
|
||||
|
||||
if (expanderTabs.containsKey(offertype))
|
||||
expanderTabs[offertype]!!.innerTable.add(tradeButton).row()
|
||||
if (expanderTabs.containsKey(offerType))
|
||||
expanderTabs[offerType]!!.innerTable.add(tradeButton).row()
|
||||
else table.add(tradeButton).row()
|
||||
}
|
||||
}
|
||||
widget = table
|
||||
actor = table
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user