Added icons to resource trades & war declarations (#5376)

This commit is contained in:
Xander Lenstra 2021-10-03 10:46:27 +02:00 committed by GitHub
parent 091622612c
commit 238cbb782a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -56,9 +56,10 @@ class OffersListScroll(
for (offerType in values()) { for (offerType in values()) {
val offersOfType = offersToDisplay.filter { it.type == offerType } val offersOfType = offersToDisplay.filter { it.type == offerType }
.sortedWith(compareBy({ .sortedWith(compareBy(
if (UncivGame.Current.settings.orderTradeOffersByAmount) -it.amount else 0}, { if (UncivGame.Current.settings.orderTradeOffersByAmount) -it.amount else 0 },
{if (it.type==City) it.getOfferText() else it.name.tr()})) { if (it.type==City) it.getOfferText() else it.name.tr() }
))
if (expanderTabs.containsKey(offerType)) { if (expanderTabs.containsKey(offerType)) {
expanderTabs[offerType]!!.innerTable.clear() expanderTabs[offerType]!!.innerTable.clear()
@ -67,6 +68,15 @@ class OffersListScroll(
for (offer in offersOfType) { for (offer in offersOfType) {
val tradeButton = offer.getOfferText(untradableOffers.filter { it.resource.name == offer.name }.sumOf { it.amount }).toTextButton() val tradeButton = offer.getOfferText(untradableOffers.filter { it.resource.name == offer.name }.sumOf { it.amount }).toTextButton()
tradeButton.labelCell.pad(5f)
when (offer.type) {
Luxury_Resource, Strategic_Resource ->
tradeButton.add(ImageGetter.getResourceImage(offer.name, 30f))
WarDeclaration ->
tradeButton.add(ImageGetter.getNationIndicator(UncivGame.Current.gameInfo.ruleSet.nations[offer.name]!!, 30f))
else -> Unit // Remove warning
}
val amountPerClick = val amountPerClick =
if (offer.type == Gold) 50 if (offer.type == Gold) 50
else 1 else 1

View File

@ -7,17 +7,18 @@ import com.unciv.logic.trade.TradeRequest
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
class TradeTable(val otherCivilization: CivilizationInfo, stage: DiplomacyScreen): Table(CameraStageBaseScreen.skin){ class TradeTable(val otherCivilization: CivilizationInfo, stage: DiplomacyScreen): Table(CameraStageBaseScreen.skin) {
val currentPlayerCiv = otherCivilization.gameInfo.getCurrentPlayerCivilization() val currentPlayerCiv = otherCivilization.gameInfo.getCurrentPlayerCivilization()
var tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization) var tradeLogic = TradeLogic(currentPlayerCiv,otherCivilization)
var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() } var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
var offerColumnsTableWrapper = Table() // This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way // This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way
var offerColumnsTableWrapper = Table()
val offerButton = "Offer trade".toTextButton() val offerButton = "Offer trade".toTextButton()
fun isTradeOffered() = otherCivilization.tradeRequests.any{it.requestingCiv==currentPlayerCiv.civName} fun isTradeOffered() = otherCivilization.tradeRequests.any { it.requestingCiv == currentPlayerCiv.civName }
fun retractOffer(){ fun retractOffer(){
otherCivilization.tradeRequests.removeAll { it.requestingCiv==currentPlayerCiv.civName } otherCivilization.tradeRequests.removeAll { it.requestingCiv == currentPlayerCiv.civName }
currentPlayerCiv.updateDetailedCivResources() currentPlayerCiv.updateDetailedCivResources()
offerButton.setText("Offer trade".tr()) offerButton.setText("Offer trade".tr())
} }
@ -28,7 +29,7 @@ class TradeTable(val otherCivilization: CivilizationInfo, stage: DiplomacyScreen
val lowerTable = Table().apply { defaults().pad(10f) } val lowerTable = Table().apply { defaults().pad(10f) }
val existingOffer = otherCivilization.tradeRequests.firstOrNull{it.requestingCiv==currentPlayerCiv.civName} val existingOffer = otherCivilization.tradeRequests.firstOrNull { it.requestingCiv == currentPlayerCiv.civName }
if (existingOffer != null){ if (existingOffer != null){
tradeLogic.currentTrade.set(existingOffer.trade.reverse()) tradeLogic.currentTrade.set(existingOffer.trade.reverse())
offerColumnsTable.update() offerColumnsTable.update()