From 849129ac6569991dff04769d9245053c95d4357a Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 9 Jul 2018 22:43:32 +0300 Subject: [PATCH] Added trade translation texts Added duration to trade screen buttons --- android/assets/jsons/Translations.json | 13 +++++++++ android/build.gradle | 4 +-- core/src/com/unciv/ui/TradeScreen.kt | 40 ++++++++++++-------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/android/assets/jsons/Translations.json b/android/assets/jsons/Translations.json index b8c541d2c3..24e26c747f 100644 --- a/android/assets/jsons/Translations.json +++ b/android/assets/jsons/Translations.json @@ -2361,4 +2361,17 @@ Dutch:" Het/De [policyBranch] beleid is ontgrendeld!" // depends on what brach it is } // EG Rationalism policy branch unlocked! + // Trade + "Trade with [otherCiv]":{} + "Offer trade":{} + "What do you have in mind?":{} + "Our items":{} + "Our trade offer":{} + "[otherCiv]'s trade offer":{} + "[otherCiv]'s items":{} + "Pleasure doing business with you!":{} + "I think not.":{} + "That is acceptable.":{} + "Accept":{} + } diff --git a/android/build.gradle b/android/build.gradle index 97c2e05dc0..9b2fcf8281 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.game" minSdkVersion 14 targetSdkVersion 26 - versionCode 97 - versionName "2.6.0" + versionCode 98 + versionName "2.6.1" } buildTypes { release { diff --git a/core/src/com/unciv/ui/TradeScreen.kt b/core/src/com/unciv/ui/TradeScreen.kt index 7c68867269..20e9149931 100644 --- a/core/src/com/unciv/ui/TradeScreen.kt +++ b/core/src/com/unciv/ui/TradeScreen.kt @@ -22,12 +22,6 @@ enum class TradeType{ data class TradeOffer(var name:String, var type:TradeType, var duration:Int, var amount:Int) { constructor() : this("",TradeType.Gold,0,0) // so that the json deserializer can work - - fun getText(): String { - var text = "{$name}" - if(duration>0) text += " ($duration {turns})" - return text.tr() - } } class TradeOffersList:ArrayList(){ @@ -64,8 +58,8 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre val currentTrade = Trade() val table = Table(skin) - val tradeText = Label("What do you have in mind?",skin) - val offerButton = TextButton("Offer trade",skin) + val tradeText = Label("What do you have in mind?".tr(),skin) + val offerButton = TextButton("Offer trade".tr(),skin) init { val closeButton = TextButton("Close".tr(), skin) @@ -79,14 +73,14 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre lowerTable.add(tradeText).colspan(2).row() offerButton.addClickListener { - if(offerButton.text.toString() == "Offer trade") { + if(offerButton.text.toString() == "Offer trade".tr()) { if (isTradeAcceptable(currentTrade)){ - tradeText.setText("That is acceptable.") - offerButton.setText("Accept") + tradeText.setText("That is acceptable.".tr()) + offerButton.setText("Accept".tr()) } - else tradeText.setText("I think not.") + else tradeText.setText("I think not.".tr()) } - else if(offerButton.text.toString() == "Accept"){ + else if(offerButton.text.toString() == "Accept".tr()){ civInfo.diplomacy[otherCivilization.civName]!!.trades.add(currentTrade) otherCivilization.diplomacy[civInfo.civName]!!.trades.add(currentTrade.reverse()) @@ -106,7 +100,7 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre val newTradeScreen = TradeScreen(otherCivilization) UnCivGame.Current.screen = newTradeScreen - newTradeScreen.tradeText.setText("Pleasure doing business with you!") + newTradeScreen.tradeText.setText("Pleasure doing business with you!".tr()) } } @@ -127,10 +121,10 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre val ourOffersTable = getTableOfOffers(currentTrade.ourOffers, ourAvailableOffers) val theirOffersTable = getTableOfOffers(currentTrade.theirOffers, theirAvailableOffers) val theirAvailableOffersTable = getTableOfOffers(theirAvailableOffers, currentTrade.theirOffers) - table.add("Our items") - table.add("Our trade offer") - table.add(otherCivilization.civName+"'s trade offer") - table.add(otherCivilization.civName+"'s items").row() + table.add("Our items".tr()) + table.add("Our trade offer".tr()) + table.add("[${otherCivilization.civName}]'s trade offer".tr()) + table.add("[${otherCivilization.civName}]'s items".tr()).row() table.add(ourAvailableOffersTable).size(stage.width/4,stage.width/2) table.add(ourOffersTable).size(stage.width/4,stage.width/2) table.add(theirOffersTable).size(stage.width/4,stage.width/2) @@ -142,7 +136,9 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre fun getTableOfOffers(offers: TradeOffersList, correspondingOffers: TradeOffersList): ScrollPane { val table= Table(skin).apply { defaults().pad(5f) } for(offer in offers) { - val tb = TextButton(offer.name+" ("+offer.amount+")",skin) + var buttonText = offer.name+" ("+offer.amount+")" + if(offer.duration>1) buttonText+="\n"+offer.duration+" {turns}".tr() + val tb = TextButton(buttonText,skin) val amountPerClick = if(offer.type==TradeType.Gold) 50 else 1 @@ -151,8 +147,8 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre val amountTransferred = min(amountPerClick, offer.amount) offers += offer.copy(amount = -amountTransferred) correspondingOffers += offer.copy(amount = amountTransferred) - offerButton.setText("Offer trade") - tradeText.setText("What do you have in mind?") + offerButton.setText("Offer trade".tr()) + tradeText.setText("What do you have in mind?".tr()) update() } else tb.disable() // for instance we have negative gold @@ -168,7 +164,7 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre else TradeType.Strategic_Resource offers.add(TradeOffer(entry.key.name, resourceTradeType, 30, entry.value)) } - offers.add(TradeOffer("Gold",TradeType.Gold,0,civInfo.gold)) + offers.add(TradeOffer("Gold".tr(),TradeType.Gold,0,civInfo.gold)) return offers }