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