Trade offers better sorting with user choice (#2180)
#2152 is nice but sorts by internal key, thus translations are not taken into account and cities are sorted by their guid Also moving larger amounts to the top may not be everyone's taste so this offers the user a choice
This commit is contained in:
parent
076821a181
commit
701ddcb76b
3 changed files with 10 additions and 2 deletions
|
@ -31,6 +31,7 @@ class GameSettings {
|
|||
var multiplayerTurnCheckerEnabled = true
|
||||
var multiplayerTurnCheckerPersistentNotificationEnabled = true
|
||||
var multiplayerTurnCheckerDelayInMinutes = 5
|
||||
var orderTradeOffersByAmount = true
|
||||
|
||||
init {
|
||||
// 26 = Android Oreo. Versions below may display permanent icon in notification bar.
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.trade.TradeOffer
|
||||
import com.unciv.logic.trade.TradeOffersList
|
||||
import com.unciv.logic.trade.TradeType
|
||||
|
@ -42,8 +43,8 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
|||
}
|
||||
|
||||
for (offerType in values()) {
|
||||
val offersOfType = offersToDisplay.filter { it.type == offerType }.
|
||||
sortedBy { it.name }.sortedByDescending { it.amount }
|
||||
val offersOfType = offersToDisplay.filter { it.type == offerType }
|
||||
.sortedWith(compareBy({if (UncivGame.Current.settings.orderTradeOffersByAmount) -it.amount else 0},{if (it.type==City) it.getOfferText() else it.name.tr()}))
|
||||
|
||||
if (expanderTabs.containsKey(offerType)) {
|
||||
expanderTabs[offerType]!!.innerTable.clear()
|
||||
|
|
|
@ -76,6 +76,12 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
|||
update()
|
||||
}
|
||||
|
||||
innerTable.add("Order trade offers by amount".toLabel())
|
||||
addButton(innerTable, if (settings.orderTradeOffersByAmount) "Yes" else "No") {
|
||||
settings.orderTradeOffersByAmount = !settings.orderTradeOffersByAmount
|
||||
update()
|
||||
}
|
||||
|
||||
addLanguageSelectBox(innerTable)
|
||||
|
||||
addResolutionSelectBox(innerTable)
|
||||
|
|
Loading…
Reference in a new issue