mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 03:38:55 +07:00
Add another confirmation when buying a religious unit in a city that … (#9570)
* Add another confirmation when buying a religious unit in a city that doesn't follow a religion founded by the city's civ. * There's other stuff that can be purchased with Faith. Better to use UniqueType.Religious unit I guess. * Add string to template.properties * One more space to make unit tests happy * Better template.properties * Reinsert trailing space * Introduce Constants entry for "Cancel" * Redo ConfirmBuyPopup * Dev console command to tweak religion pressures * Translation templates and one test --------- Co-authored-by: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com>
This commit is contained in:
@ -1209,6 +1209,8 @@ Buy for [amount] gold = Für [amount] Gold kaufen
|
||||
Buy = Kaufen
|
||||
Currently you have [amount] [stat]. = Zur Zeit besitzt du [amount] [stat].
|
||||
Would you like to purchase [constructionName] for [buildingGoldCost] [stat]? = [constructionName] für [buildingGoldCost] [stat] kaufen?
|
||||
You are buying a religious unit in a city that doesn't follow the religion you founded ([yourReligion]). This means that the unit is tied to that foreign religion ([majorityReligion]) and will be less useful. = Du möchtest eine an [majorityReligion] glaubende Einheit kaufen, obwohl Du [yourReligion] gegründet hast? Das wird nicht ganz so nützlich sein!
|
||||
Are you really sure you want to purchase this unit? = Bist du dir da wirklich ganz sicher?
|
||||
Purchase = Kaufen
|
||||
No space available to place [unit] near [city] = Kein Platz verfügbar, um [unit] nahe [city] zu platzieren
|
||||
Maintenance cost = Wartungskosten
|
||||
@ -6701,4 +6703,3 @@ In the Resources overview, click on a resource icon to center the world screen o
|
||||
Alternatively, click on the "Unimproved" number to center the world screen only on owned tiles where the resource is not improved. =
|
||||
# Requires translation!
|
||||
If more than one tile is available, click repeatedly on the notification to cycle through all of them. =
|
||||
|
||||
|
@ -1194,6 +1194,8 @@ Buy for [amount] gold =
|
||||
Buy =
|
||||
Currently you have [amount] [stat]. =
|
||||
Would you like to purchase [constructionName] for [buildingGoldCost] [stat]? =
|
||||
You are buying a religious unit in a city that doesn't follow the religion you founded ([yourReligion]). This means that the unit is tied to that foreign religion ([majorityReligion]) and will be less useful. =
|
||||
Are you really sure you want to purchase this unit? =
|
||||
Purchase =
|
||||
No space available to place [unit] near [city] =
|
||||
Maintenance cost =
|
||||
|
@ -71,6 +71,7 @@ object Constants {
|
||||
|
||||
const val OK = "OK"
|
||||
const val close = "Close"
|
||||
const val cancel = "Cancel"
|
||||
const val yes = "Yes"
|
||||
const val no = "No"
|
||||
const val loading = "Loading..."
|
||||
|
@ -144,7 +144,7 @@ open class FileChooser(
|
||||
fileNameCell = add().colspan(2).growX()
|
||||
row()
|
||||
|
||||
addCloseButton("Cancel") {
|
||||
addCloseButton(Constants.cancel) {
|
||||
reportResult(false)
|
||||
}
|
||||
okButton = addOKButton(Constants.OK) {
|
||||
|
@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.FocusListener
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.event.EventBus
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.components.extensions.getAscendant
|
||||
@ -173,7 +174,7 @@ class TextfieldPopup(
|
||||
.colspan(2)
|
||||
.row()
|
||||
|
||||
addCloseButton("Cancel")
|
||||
addCloseButton(Constants.cancel)
|
||||
.left()
|
||||
addOKButton { textField.text = popupTextfield.text }
|
||||
.right()
|
||||
|
@ -3,9 +3,10 @@ package com.unciv.ui.popups
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.input.KeyboardBinding
|
||||
import com.unciv.Constants
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.components.input.KeyboardBinding
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
|
||||
/** Variant of [Popup] pre-populated with one label, plus confirm and cancel buttons
|
||||
* @param stageToShowOn Parent [Stage], see [Popup.stageToShowOn]
|
||||
@ -39,7 +40,7 @@ open class ConfirmPopup(
|
||||
init {
|
||||
promptLabel.setAlignment(Align.center)
|
||||
add(promptLabel).colspan(2).row()
|
||||
addCloseButton("Cancel", KeyboardBinding.Cancel, action = restoreDefault)
|
||||
addCloseButton(Constants.cancel, KeyboardBinding.Cancel, action = restoreDefault)
|
||||
val confirmStyleName = if (isConfirmPositive) "positive" else "negative"
|
||||
val confirmStyle = BaseScreen.skin.get(confirmStyleName, TextButtonStyle::class.java)
|
||||
addOKButton(confirmText, KeyboardBinding.Confirm, confirmStyle, action = action)
|
||||
|
@ -12,6 +12,7 @@ import com.unciv.GUI
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.Religion
|
||||
import com.unciv.models.UncivSound
|
||||
import com.unciv.models.ruleset.Building
|
||||
import com.unciv.models.ruleset.IConstruction
|
||||
@ -25,8 +26,6 @@ import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.audio.SoundPlayer
|
||||
import com.unciv.ui.components.widgets.ColorMarkupLabel
|
||||
import com.unciv.ui.components.widgets.ExpanderTab
|
||||
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
|
||||
import com.unciv.ui.components.extensions.addBorder
|
||||
import com.unciv.ui.components.extensions.addCell
|
||||
@ -45,9 +44,10 @@ import com.unciv.ui.components.input.keyShortcuts
|
||||
import com.unciv.ui.components.input.onActivation
|
||||
import com.unciv.ui.components.input.onClick
|
||||
import com.unciv.ui.components.input.onRightClick
|
||||
import com.unciv.ui.components.widgets.ColorMarkupLabel
|
||||
import com.unciv.ui.components.widgets.ExpanderTab
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.CityScreenConstructionMenu
|
||||
import com.unciv.ui.popups.ConfirmPopup
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.popups.closeAllPopups
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
@ -667,16 +667,44 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
||||
if (!isConstructionPurchaseAllowed(construction, stat, constructionStatBuyCost)) return
|
||||
|
||||
cityScreen.closeAllPopups()
|
||||
ConfirmBuyPopup(construction, stat,constructionStatBuyCost, tile)
|
||||
}
|
||||
|
||||
val purchasePrompt = "Currently you have [${city.getStatReserve(stat)}] [${stat.name}].".tr() + "\n\n" +
|
||||
"Would you like to purchase [${construction.name}] for [$constructionStatBuyCost] [${stat.character}]?".tr()
|
||||
ConfirmPopup(
|
||||
cityScreen,
|
||||
purchasePrompt,
|
||||
"Purchase",
|
||||
true,
|
||||
restoreDefault = { cityScreen.update() }
|
||||
) { purchaseConstruction(construction, stat, tile) }.open()
|
||||
private inner class ConfirmBuyPopup(
|
||||
construction: INonPerpetualConstruction,
|
||||
stat: Stat,
|
||||
constructionStatBuyCost: Int,
|
||||
tile: Tile?
|
||||
) : Popup(cityScreen.stage) {
|
||||
init {
|
||||
val city = cityScreen.city
|
||||
val balance = city.getStatReserve(stat)
|
||||
val majorityReligion = city.religion.getMajorityReligion()
|
||||
val yourReligion = city.civ.religionManager.religion
|
||||
val isBuyingWithFaithForForeignReligion = construction.hasUnique(UniqueType.ReligiousUnit) && majorityReligion != yourReligion
|
||||
|
||||
addGoodSizedLabel("Currently you have [$balance] [${stat.name}].").padBottom(10f).row()
|
||||
if (isBuyingWithFaithForForeignReligion) {
|
||||
// Earlier tests should forbid this Popup unless both religions are non-null, but to be safe:
|
||||
fun Religion?.getName() = this?.getReligionDisplayName() ?: Constants.unknownCityName
|
||||
addGoodSizedLabel("You are buying a religious unit in a city that doesn't follow the religion you founded ([${yourReligion.getName()}]). " +
|
||||
"This means that the unit is tied to that foreign religion ([${majorityReligion.getName()}]) and will be less useful.").row()
|
||||
addGoodSizedLabel("Are you really sure you want to purchase this unit?", Constants.headingFontSize).run {
|
||||
actor.color = Color.FIREBRICK
|
||||
padBottom(10f)
|
||||
row()
|
||||
}
|
||||
}
|
||||
addGoodSizedLabel("Would you like to purchase [${construction.name}] for [$constructionStatBuyCost] [${stat.character}]?").row()
|
||||
|
||||
addCloseButton(Constants.cancel, KeyboardBinding.Cancel) { cityScreen.update() }
|
||||
val confirmStyle = BaseScreen.skin.get("positive", TextButton.TextButtonStyle::class.java)
|
||||
addOKButton("Purchase", KeyboardBinding.Confirm, confirmStyle) {
|
||||
purchaseConstruction(construction, stat, tile)
|
||||
}
|
||||
equalizeLastTwoButtonWidths()
|
||||
open(true)
|
||||
}
|
||||
}
|
||||
|
||||
/** This tests whether the buy button should be _shown_ */
|
||||
|
@ -177,7 +177,22 @@ class ConsoleCityCommands : ConsoleCommandNode {
|
||||
val city = selectedTile.getCity() ?: return@ConsoleAction DevConsoleResponse.error("No city for selected tile")
|
||||
city.expansion.relinquishOwnership(selectedTile)
|
||||
return@ConsoleAction DevConsoleResponse.OK
|
||||
})
|
||||
},
|
||||
|
||||
"religion" to ConsoleAction { console, params ->
|
||||
if (params.size != 2)
|
||||
return@ConsoleAction DevConsoleResponse.hint("Format: city religion <name> <±pressure>")
|
||||
val city = console.screen.bottomUnitTable.selectedCity
|
||||
?: return@ConsoleAction DevConsoleResponse.hint("Select a city first")
|
||||
val religion = city.civ.gameInfo.religions.keys.firstOrNull { it.toCliInput() == params[0] }
|
||||
?: return@ConsoleAction DevConsoleResponse.error("'${params[0]}' is not a known religion")
|
||||
val pressure = params[1].toIntOrNull()
|
||||
?: return@ConsoleAction DevConsoleResponse.error("'${params[1]}' is not an integer")
|
||||
city.religion.addPressure(religion, pressure.coerceAtLeast(-city.religion.getPressures()[religion]))
|
||||
city.religion.updatePressureOnPopulationChange(0)
|
||||
return@ConsoleAction DevConsoleResponse.OK
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
class ConsoleTileCommands: ConsoleCommandNode {
|
||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
@ -90,7 +91,7 @@ class EspionageOverviewScreen(val civInfo: Civilization) : PickerScreen(true) {
|
||||
resetSelection()
|
||||
selectedSpyButton = moveSpyButton
|
||||
selectedSpy = spy
|
||||
selectedSpyButton!!.label.setText("Cancel".tr())
|
||||
selectedSpyButton!!.label.setText(Constants.cancel.tr())
|
||||
for ((button, city) in moveSpyHereButtons) {
|
||||
// For now, only allow spies to be sent to cities of other major civs and their hideout
|
||||
// Not own cities as counterintelligence isn't implemented
|
||||
|
Reference in New Issue
Block a user