mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Cannot open multiple gold selection popups in trade table
This commit is contained in:
parent
fa5d2b6f49
commit
30396239c1
@ -65,8 +65,9 @@ class OfferColumnsTable(val tradeLogic: TradeLogic, val screen: DiplomacyScreen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun openGoldSelectionPopup(offer: TradeOffer, ourOffers: TradeOffersList, offeringCiv: CivilizationInfo) {
|
class goldSelectionPopup(screen: DiplomacyScreen, offer: TradeOffer, ourOffers: TradeOffersList,
|
||||||
val selectionPopup = Popup(screen)
|
offeringCiv: CivilizationInfo, onChange: () -> Unit):Popup(screen){
|
||||||
|
init {
|
||||||
val existingGoldOffer = ourOffers.firstOrNull { it.type == TradeType.Gold }
|
val existingGoldOffer = ourOffers.firstOrNull { it.type == TradeType.Gold }
|
||||||
if (existingGoldOffer != null)
|
if (existingGoldOffer != null)
|
||||||
offer.amount = existingGoldOffer.amount
|
offer.amount = existingGoldOffer.amount
|
||||||
@ -85,14 +86,21 @@ class OfferColumnsTable(val tradeLogic: TradeLogic, val screen: DiplomacyScreen,
|
|||||||
minitable.add(amountLabel)
|
minitable.add(amountLabel)
|
||||||
minitable.add("+50".toTextButton().onClick { incrementAmount(50) })
|
minitable.add("+50".toTextButton().onClick { incrementAmount(50) })
|
||||||
minitable.add("+500".toTextButton().onClick { incrementAmount(500) })
|
minitable.add("+500".toTextButton().onClick { incrementAmount(500) })
|
||||||
selectionPopup.add(minitable).row()
|
|
||||||
|
|
||||||
selectionPopup.addCloseButton {
|
add(minitable).row()
|
||||||
|
|
||||||
|
addCloseButton {
|
||||||
if (existingGoldOffer == null)
|
if (existingGoldOffer == null)
|
||||||
ourOffers.add(offer)
|
ourOffers.add(offer)
|
||||||
else existingGoldOffer.amount = offer.amount
|
else existingGoldOffer.amount = offer.amount
|
||||||
onChange()
|
onChange()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openGoldSelectionPopup(offer: TradeOffer, ourOffers: TradeOffersList, offeringCiv: CivilizationInfo) {
|
||||||
|
if (screen.stage.actors.any { it is goldSelectionPopup }) return
|
||||||
|
val selectionPopup = goldSelectionPopup(screen, offer, ourOffers, offeringCiv, onChange)
|
||||||
selectionPopup.open()
|
selectionPopup.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user