From 1ef883ecddfaee8692692ac4e312f430a42df37c Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 21 Aug 2023 15:41:15 -0400 Subject: [PATCH] ImprovementPicker screen displays tile owner civ and city (#9942) * Added owner civ and city to the ImprovementPicker screen with translation * Switched tileOwnerText from var to val * Changed unowned tile message and city name link to city screen --- .../jsons/translations/template.properties | 3 +++ .../pickerscreens/ImprovementPickerScreen.kt | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 5848d9ce87..1ac5768867 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1170,6 +1170,9 @@ No space available to place [unit] near [city] = Maintenance cost = Pick construction = Pick improvement = +Tile owned by [civName] - [cityName] = +Tile owned by [civName] (You) = +Unowned tile = Provides [resource] = Provides [amount] [resource] = Replaces [improvement] = diff --git a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt index f3457debc9..070fb00d1a 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt @@ -16,10 +16,12 @@ import com.unciv.ui.components.Fonts import com.unciv.ui.components.UncivTooltip.Companion.addTooltip import com.unciv.ui.components.extensions.disable import com.unciv.ui.components.extensions.toLabel +import com.unciv.ui.components.extensions.toTextButton import com.unciv.ui.components.input.keyShortcuts import com.unciv.ui.components.input.onClick import com.unciv.ui.components.input.onDoubleClick import com.unciv.ui.images.ImageGetter +import com.unciv.ui.screens.cityscreen.CityScreen import kotlin.math.roundToInt class ImprovementPickerScreen( @@ -203,6 +205,22 @@ class ImprovementPickerScreen( regularImprovements.row() } + var ownerTable = Table() + if (tile.getOwner() == null) { + ownerTable.add("Unowned tile".tr().toLabel()) + } else if (tile.getOwner()!!.isCurrentPlayer()) { + val button = tile.getCity()!!.name.toTextButton(hideIcons = true) + button.onClick { + this.game.pushScreen(CityScreen(tile.getCity()!!,null,tile)) + } + ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] (You)".tr().toLabel()).padLeft(10f) + ownerTable.add(button).padLeft(20f) + } else { + ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] - [${tile.getCity()!!.name}]".tr().toLabel()).padLeft(10f) + } + + topTable.add(ownerTable) + topTable.row() topTable.add(regularImprovements) }