mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Implemented renaming of religions (#5057)
* Implemented renaming of religions * Made AskForText display error on invalid input, implemented recommended changes * Almost forgot the translatable strings in the new popup
This commit is contained in:
parent
d0dbb27e00
commit
9575b5bf66
BIN
android/Images/OtherIcons/Pencil.png
Normal file
BIN
android/Images/OtherIcons/Pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 964 KiB After Width: | Height: | Size: 967 KiB |
@ -701,6 +701,8 @@ Worked by [cityName] =
|
|||||||
Lock =
|
Lock =
|
||||||
Unlock =
|
Unlock =
|
||||||
Move to city =
|
Move to city =
|
||||||
|
Invalid input! Please enter a different string. =
|
||||||
|
Please enter some text =
|
||||||
|
|
||||||
# Technology UI
|
# Technology UI
|
||||||
|
|
||||||
@ -766,7 +768,6 @@ Spread [religionName] =
|
|||||||
Remove Heresy =
|
Remove Heresy =
|
||||||
Found a Religion =
|
Found a Religion =
|
||||||
Enhance a Religion =
|
Enhance a Religion =
|
||||||
Enhance [religionName] =
|
|
||||||
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
|
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
|
||||||
You have entered the [newEra]! =
|
You have entered the [newEra]! =
|
||||||
[civName] has entered the [eraName]! =
|
[civName] has entered the [eraName]! =
|
||||||
@ -1024,8 +1025,10 @@ Policy branch: [branchName] =
|
|||||||
# Religions
|
# Religions
|
||||||
|
|
||||||
Choose an Icon and name for your Religion =
|
Choose an Icon and name for your Religion =
|
||||||
|
Choose a name for your religion =
|
||||||
Choose a [beliefType] belief! =
|
Choose a [beliefType] belief! =
|
||||||
Found [religionName] =
|
Found [religionName] =
|
||||||
|
Enhance [religionName] =
|
||||||
Choose a pantheon =
|
Choose a pantheon =
|
||||||
Found Religion =
|
Found Religion =
|
||||||
Found Pantheon =
|
Found Pantheon =
|
||||||
|
@ -330,7 +330,7 @@ object NextTurnAutomation {
|
|||||||
private fun foundReligion(civInfo: CivilizationInfo) {
|
private fun foundReligion(civInfo: CivilizationInfo) {
|
||||||
if (civInfo.religionManager.religionState != ReligionState.FoundingReligion) return
|
if (civInfo.religionManager.religionState != ReligionState.FoundingReligion) return
|
||||||
val religionIcon = civInfo.gameInfo.ruleSet.religions
|
val religionIcon = civInfo.gameInfo.ruleSet.religions
|
||||||
.filterNot { civInfo.gameInfo.religions.values.map { religion -> religion.iconName }.contains(it) }
|
.filterNot { civInfo.gameInfo.religions.values.map { religion -> religion.name }.contains(it) }
|
||||||
.randomOrNull()
|
.randomOrNull()
|
||||||
?: return // Wait what? How did we pass the checking when using a great prophet but not this?
|
?: return // Wait what? How did we pass the checking when using a great prophet but not this?
|
||||||
val chosenBeliefs = chooseBeliefs(civInfo, civInfo.religionManager.getBeliefsToChooseAtFounding()).toList()
|
val chosenBeliefs = chooseBeliefs(civInfo, civInfo.religionManager.getBeliefsToChooseAtFounding()).toList()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.logic.civilization
|
package com.unciv.logic.civilization
|
||||||
|
|
||||||
import com.unciv.Constants
|
|
||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.models.Religion
|
import com.unciv.models.Religion
|
||||||
import com.unciv.models.ruleset.Belief
|
import com.unciv.models.ruleset.Belief
|
||||||
@ -34,17 +33,18 @@ class ReligionManager {
|
|||||||
var religionState = ReligionState.None
|
var religionState = ReligionState.None
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@Transient
|
// These cannot be transient, as saving and loading after using a great prophet but before
|
||||||
|
// founding a religion would break :(
|
||||||
private var foundingCityId: String? = null
|
private var foundingCityId: String? = null
|
||||||
// Only used for keeping track of the city a prophet was used when founding a religion
|
// Only used for keeping track of the city a prophet was used when founding a religion
|
||||||
|
|
||||||
@Transient
|
|
||||||
private var shouldChoosePantheonBelief: Boolean = false
|
private var shouldChoosePantheonBelief: Boolean = false
|
||||||
|
|
||||||
|
|
||||||
fun clone(): ReligionManager {
|
fun clone(): ReligionManager {
|
||||||
val clone = ReligionManager()
|
val clone = ReligionManager()
|
||||||
clone.foundingCityId = foundingCityId
|
clone.foundingCityId = foundingCityId
|
||||||
|
clone.shouldChoosePantheonBelief = shouldChoosePantheonBelief
|
||||||
clone.storedFaith = storedFaith
|
clone.storedFaith = storedFaith
|
||||||
clone.religionState = religionState
|
clone.religionState = religionState
|
||||||
clone.greatProphetsEarned = greatProphetsEarned
|
clone.greatProphetsEarned = greatProphetsEarned
|
||||||
@ -200,9 +200,9 @@ class ReligionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun foundReligion(iconName: String, name: String, beliefs: List<Belief>) {
|
fun foundReligion(displayName: String, name: String, beliefs: List<Belief>) {
|
||||||
val newReligion = Religion(name, civInfo.gameInfo, civInfo.civName)
|
val newReligion = Religion(name, civInfo.gameInfo, civInfo.civName)
|
||||||
newReligion.iconName = iconName
|
newReligion.displayName = displayName
|
||||||
if (religion != null) {
|
if (religion != null) {
|
||||||
newReligion.followerBeliefs.addAll(religion!!.followerBeliefs)
|
newReligion.followerBeliefs.addAll(religion!!.followerBeliefs)
|
||||||
newReligion.founderBeliefs.addAll(religion!!.founderBeliefs)
|
newReligion.founderBeliefs.addAll(religion!!.founderBeliefs)
|
||||||
|
@ -106,10 +106,12 @@ class MapUnit {
|
|||||||
* attention to combined names (renamed units, religion).
|
* attention to combined names (renamed units, religion).
|
||||||
*/
|
*/
|
||||||
fun displayName(): String {
|
fun displayName(): String {
|
||||||
val name = if (instanceName == null) name
|
val baseName =
|
||||||
else "$instanceName ({${name}})"
|
if (instanceName == null) "[$name]"
|
||||||
return if (religion != null) "[$name] ([$religion])"
|
else "instanceName ([$name])"
|
||||||
else name
|
|
||||||
|
return if (religion == null) baseName
|
||||||
|
else "$baseName ([${getReligionDisplayName()}])"
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentMovement: Float = 0f
|
var currentMovement: Float = 0f
|
||||||
@ -969,6 +971,11 @@ class MapUnit {
|
|||||||
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
|
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getReligionDisplayName(): String? {
|
||||||
|
if (religion == null) return null
|
||||||
|
return civInfo.gameInfo.religions[religion]!!.displayName ?: religion
|
||||||
|
}
|
||||||
|
|
||||||
fun religiousActionsUnitCanDo(): Sequence<String> {
|
fun religiousActionsUnitCanDo(): Sequence<String> {
|
||||||
return getMatchingUniques("Can [] [] times")
|
return getMatchingUniques("Can [] [] times")
|
||||||
.map { it.params[0] }
|
.map { it.params[0] }
|
||||||
|
@ -10,7 +10,7 @@ import com.unciv.models.stats.INamed
|
|||||||
class Religion() : INamed {
|
class Religion() : INamed {
|
||||||
|
|
||||||
override lateinit var name: String
|
override lateinit var name: String
|
||||||
var iconName: String = "Pantheon"
|
var displayName: String? = null
|
||||||
lateinit var foundingCivName: String
|
lateinit var foundingCivName: String
|
||||||
|
|
||||||
var founderBeliefs: HashSet<String> = hashSetOf()
|
var founderBeliefs: HashSet<String> = hashSetOf()
|
||||||
@ -21,13 +21,14 @@ class Religion() : INamed {
|
|||||||
|
|
||||||
constructor(name: String, gameInfo: GameInfo, foundingCivName: String) : this() {
|
constructor(name: String, gameInfo: GameInfo, foundingCivName: String) : this() {
|
||||||
this.name = name
|
this.name = name
|
||||||
|
this.displayName = name
|
||||||
this.foundingCivName = foundingCivName
|
this.foundingCivName = foundingCivName
|
||||||
this.gameInfo = gameInfo
|
this.gameInfo = gameInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clone(): Religion {
|
fun clone(): Religion {
|
||||||
val toReturn = Religion(name, gameInfo, foundingCivName)
|
val toReturn = Religion(name, gameInfo, foundingCivName)
|
||||||
toReturn.iconName = iconName
|
toReturn.displayName = displayName
|
||||||
toReturn.founderBeliefs.addAll(founderBeliefs)
|
toReturn.founderBeliefs.addAll(founderBeliefs)
|
||||||
toReturn.followerBeliefs.addAll(followerBeliefs)
|
toReturn.followerBeliefs.addAll(followerBeliefs)
|
||||||
return toReturn
|
return toReturn
|
||||||
@ -37,6 +38,10 @@ class Religion() : INamed {
|
|||||||
this.gameInfo = gameInfo
|
this.gameInfo = gameInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getIconName() =
|
||||||
|
if (isPantheon()) "Pantheon"
|
||||||
|
else name
|
||||||
|
|
||||||
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
|
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
|
||||||
val rulesetBeliefs = gameInfo.ruleSet.beliefs
|
val rulesetBeliefs = gameInfo.ruleSet.beliefs
|
||||||
return beliefs.mapNotNull {
|
return beliefs.mapNotNull {
|
||||||
|
@ -215,7 +215,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean {
|
override fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean {
|
||||||
// May buy [unitFilter] units for [amount] [Stat] starting from the [eraName] at an increasing price ([amount])
|
// May buy [unitFilter] units for [amount] [Stat] [cityFilter] starting from the [eraName] at an increasing price ([amount])
|
||||||
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
||||||
.any {
|
.any {
|
||||||
matchesFilter(it.params[0])
|
matchesFilter(it.params[0])
|
||||||
|
@ -51,18 +51,16 @@ class CityScreenCityPickerTable(private val cityScreen: CityScreen) : Table() {
|
|||||||
|
|
||||||
val currentCityLabel = city.name.toLabel(fontSize = 30, fontColor = civInfo.nation.getInnerColor())
|
val currentCityLabel = city.name.toLabel(fontSize = 30, fontColor = civInfo.nation.getInnerColor())
|
||||||
if (cityScreen.canChangeState) currentCityLabel.onClick {
|
if (cityScreen.canChangeState) currentCityLabel.onClick {
|
||||||
val editCityNamePopup = Popup(cityScreen)
|
AskTextPopup(
|
||||||
val textArea = TextField(city.name, CameraStageBaseScreen.skin)
|
cityScreen,
|
||||||
textArea.alignment = Align.center
|
label = "Please enter a new name for your city",
|
||||||
editCityNamePopup.add(textArea).colspan(2).row()
|
defaultText = city.name,
|
||||||
//editCityNamePopup.name = "CityNamePopup" // debug help
|
actionOnOk = { text ->
|
||||||
editCityNamePopup.addButtonInRow("Save", KeyCharAndCode.RETURN) {
|
city.name = text
|
||||||
city.name = textArea.text
|
cityScreen.game.setScreen(CityScreen(city))
|
||||||
cityScreen.game.setScreen(CityScreen(city))
|
true
|
||||||
}
|
}
|
||||||
editCityNamePopup.addCloseButton("Cancel")
|
).open()
|
||||||
editCityNamePopup.keyboardFocus = textArea
|
|
||||||
editCityNamePopup.open()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cityNameTable.add(currentCityLabel)
|
cityNameTable.add(currentCityLabel)
|
||||||
|
@ -83,9 +83,11 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addReligionInfo() {
|
private fun addReligionInfo() {
|
||||||
val label = cityInfo.religion.getMajorityReligion()?.iconName
|
val label = cityInfo.religion.getMajorityReligion()?.displayName
|
||||||
?: "None"
|
?: "None"
|
||||||
val icon = if (label == "None") "Religion" else label
|
val icon =
|
||||||
|
if (label == "None") "Religion"
|
||||||
|
else cityInfo.religion.getMajorityReligion()!!.name
|
||||||
val expanderTab =
|
val expanderTab =
|
||||||
ExpanderTab(
|
ExpanderTab(
|
||||||
title = "Majority Religion: [$label]",
|
title = "Majority Religion: [$label]",
|
||||||
@ -104,7 +106,9 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
if (cityInfo.religion.religionThisIsTheHolyCityOf != null) {
|
if (cityInfo.religion.religionThisIsTheHolyCityOf != null) {
|
||||||
// I want this to be centered, but `.center()` doesn't seem to do anything,
|
// I want this to be centered, but `.center()` doesn't seem to do anything,
|
||||||
// regardless of where I place it :(
|
// regardless of where I place it :(
|
||||||
it.add("Holy city of: [${cityInfo.religion.religionThisIsTheHolyCityOf!!}]".toLabel()).center().colspan(2).pad(5f).row()
|
it.add(
|
||||||
|
"Holy city of: [${cityInfo.civInfo.gameInfo.religions[cityInfo.religion.religionThisIsTheHolyCityOf!!]!!.displayName}]".toLabel()
|
||||||
|
).center().colspan(2).pad(5f).row()
|
||||||
}
|
}
|
||||||
it.add(getReligionsTable()).colspan(2).pad(5f)
|
it.add(getReligionsTable()).colspan(2).pad(5f)
|
||||||
}
|
}
|
||||||
@ -128,7 +132,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
|
|
||||||
for ((religion, followerCount) in followers) {
|
for ((religion, followerCount) in followers) {
|
||||||
religionsTable.add(
|
religionsTable.add(
|
||||||
ImageGetter.getCircledReligionIcon(cityInfo.civInfo.gameInfo.religions[religion]!!.iconName, 30f)
|
ImageGetter.getCircledReligionIcon(cityInfo.civInfo.gameInfo.religions[religion]!!.getIconName(), 30f)
|
||||||
).pad(5f)
|
).pad(5f)
|
||||||
religionsTable.addSeparatorVertical(gridColor)
|
religionsTable.addSeparatorVertical(gridColor)
|
||||||
religionsTable.add(followerCount.toLabel()).pad(5f)
|
religionsTable.add(followerCount.toLabel()).pad(5f)
|
||||||
|
@ -45,7 +45,7 @@ class ReligionOverviewTable(
|
|||||||
button = Button(image, CameraStageBaseScreen.skin)
|
button = Button(image, CameraStageBaseScreen.skin)
|
||||||
} else {
|
} else {
|
||||||
button = Button(
|
button = Button(
|
||||||
ImageGetter.getCircledReligionIcon(religion.iconName, 60f),
|
ImageGetter.getCircledReligionIcon(religion.getIconName(), 60f),
|
||||||
CameraStageBaseScreen.skin
|
CameraStageBaseScreen.skin
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -66,13 +66,13 @@ class ReligionOverviewTable(
|
|||||||
private fun loadReligion(religion: Religion) {
|
private fun loadReligion(religion: Religion) {
|
||||||
statsTable.clear()
|
statsTable.clear()
|
||||||
beliefsTable.clear()
|
beliefsTable.clear()
|
||||||
topButtonLabel.setText(religion.name.tr())
|
topButtonLabel.setText(religion.displayName!!.tr())
|
||||||
for (belief in religion.getAllBeliefsOrdered()) {
|
for (belief in religion.getAllBeliefsOrdered()) {
|
||||||
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
|
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
statsTable.add("Religion Name:".toLabel())
|
statsTable.add("Religion Name:".toLabel())
|
||||||
statsTable.add(religion.name.toLabel()).pad(5f).row()
|
statsTable.add(religion.displayName!!.toLabel()).pad(5f).row()
|
||||||
statsTable.add("Founding Civ:".toLabel())
|
statsTable.add("Founding Civ:".toLabel())
|
||||||
val foundingCivName =
|
val foundingCivName =
|
||||||
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
||||||
|
@ -47,21 +47,34 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
|
|
||||||
val unitType = unit.type
|
val unitType = unit.type
|
||||||
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||||
it.unitTypes.contains(unitType.name)
|
it.unitTypes.contains(unitType.name) || unit.promotions.promotions.contains(it.name)
|
||||||
|| unit.promotions.promotions.contains(it.name) }
|
}
|
||||||
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
||||||
|
|
||||||
if(canPromoteNow && unit.instanceName == null) {
|
if (canPromoteNow && unit.instanceName == null) {
|
||||||
val renameButton = "Choose name for [${unit.name}]".toTextButton()
|
val renameButton = "Choose name for [${unit.name}]".toTextButton()
|
||||||
renameButton.isEnabled = true
|
renameButton.isEnabled = true
|
||||||
renameButton.onClick {
|
renameButton.onClick {
|
||||||
RenameUnitPopup(unit, this).open()
|
AskTextPopup(
|
||||||
|
this,
|
||||||
|
label = "Choose name for [${unit.baseUnit.name}]",
|
||||||
|
icon = ImageGetter.getUnitIcon(unit.name).surroundWithCircle(80f),
|
||||||
|
defaultText = unit.name,
|
||||||
|
actionOnOk = { userInput ->
|
||||||
|
if (userInput == unit.name)
|
||||||
|
return@AskTextPopup false
|
||||||
|
|
||||||
|
unit.instanceName = userInput
|
||||||
|
this.game.setScreen(PromotionPickerScreen(unit))
|
||||||
|
return@AskTextPopup true
|
||||||
|
}
|
||||||
|
).open()
|
||||||
}
|
}
|
||||||
availablePromotionsGroup.add(renameButton)
|
availablePromotionsGroup.add(renameButton)
|
||||||
availablePromotionsGroup.row()
|
availablePromotionsGroup.row()
|
||||||
}
|
}
|
||||||
for (promotion in promotionsForUnitType) {
|
for (promotion in promotionsForUnitType) {
|
||||||
if(promotion.name=="Heal Instantly" && unit.health==100) continue
|
if (promotion.uniqueObjects.any { it.placeholderText == "Heal this unit by [] HP" } && unit.health == 100) continue
|
||||||
val isPromotionAvailable = promotion in unitAvailablePromotions
|
val isPromotionAvailable = promotion in unitAvailablePromotions
|
||||||
val unitHasPromotion = unit.promotions.promotions.contains(promotion.name)
|
val unitHasPromotion = unit.promotions.promotions.contains(promotion.name)
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.unciv.ui.pickerscreens
|
package com.unciv.ui.pickerscreens
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
@ -16,7 +18,7 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
private val choosingCiv: CivilizationInfo,
|
private val choosingCiv: CivilizationInfo,
|
||||||
private val gameInfo: GameInfo,
|
private val gameInfo: GameInfo,
|
||||||
private val beliefsContainer: BeliefContainer,
|
private val beliefsContainer: BeliefContainer,
|
||||||
private val pickIcon: Boolean
|
private val pickIconAndName: Boolean
|
||||||
): PickerScreen(disableScroll = true) {
|
): PickerScreen(disableScroll = true) {
|
||||||
|
|
||||||
// Roughly follows the layout of the original (although I am not very good at UI designing, so please improve this)
|
// Roughly follows the layout of the original (although I am not very good at UI designing, so please improve this)
|
||||||
@ -27,14 +29,14 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
private val middlePanes = Table()
|
private val middlePanes = Table()
|
||||||
|
|
||||||
private var previouslySelectedIcon: Button? = null
|
private var previouslySelectedIcon: Button? = null
|
||||||
private var iconName: String? = null
|
private var displayName: String? = null
|
||||||
private var religionName: String? = null
|
private var religionName: String? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
closeButton.isVisible = true
|
closeButton.isVisible = true
|
||||||
setDefaultCloseAction()
|
setDefaultCloseAction()
|
||||||
|
|
||||||
if (pickIcon) setupChoosableReligionIcons()
|
if (pickIconAndName) setupChoosableReligionIcons()
|
||||||
else setupVisibleReligionIcons()
|
else setupVisibleReligionIcons()
|
||||||
|
|
||||||
updateLeftTable()
|
updateLeftTable()
|
||||||
@ -47,15 +49,16 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
topTable.addSeparator()
|
topTable.addSeparator()
|
||||||
topTable.add(middlePanes)
|
topTable.add(middlePanes)
|
||||||
|
|
||||||
rightSideButton.label = "Choose a religion".toLabel()
|
if (pickIconAndName) rightSideButton.label = "Choose a religion".toLabel()
|
||||||
|
else rightSideButton.label = "Enhance [${choosingCiv.religionManager.religion!!.displayName}]".toLabel()
|
||||||
rightSideButton.onClick(UncivSound.Choir) {
|
rightSideButton.onClick(UncivSound.Choir) {
|
||||||
choosingCiv.religionManager.chooseBeliefs(iconName, religionName, beliefsContainer.chosenBeliefs.map { it!! })
|
choosingCiv.religionManager.chooseBeliefs(displayName, religionName, beliefsContainer.chosenBeliefs.map { it!! })
|
||||||
UncivGame.Current.setWorldScreen()
|
UncivGame.Current.setWorldScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAndEnableRightSideButton() {
|
private fun checkAndEnableRightSideButton() {
|
||||||
if (pickIcon && (religionName == null || iconName == null)) return
|
if (pickIconAndName && (religionName == null || displayName == null)) return
|
||||||
if (beliefsContainer.chosenBeliefs.any { it == null }) return
|
if (beliefsContainer.chosenBeliefs.any { it == null }) return
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
}
|
}
|
||||||
@ -67,6 +70,17 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
// Note that this would require replacing 'religion.name' with 'religion.iconName' at many spots
|
// Note that this would require replacing 'religion.name' with 'religion.iconName' at many spots
|
||||||
val descriptionLabel = "Choose an Icon and name for your Religion".toLabel()
|
val descriptionLabel = "Choose an Icon and name for your Religion".toLabel()
|
||||||
|
|
||||||
|
fun changeDisplayedReligionName(newReligionName: String) {
|
||||||
|
displayName = newReligionName
|
||||||
|
rightSideButton.label = "Found [$newReligionName]".toLabel()
|
||||||
|
descriptionLabel.setText(newReligionName)
|
||||||
|
}
|
||||||
|
|
||||||
|
val changeReligionNameButton = Button(
|
||||||
|
ImageGetter.getImage("OtherIcons/Pencil").apply { this.color = Color.BLACK }.surroundWithCircle(30f),
|
||||||
|
skin
|
||||||
|
)
|
||||||
|
|
||||||
val iconsTable = Table()
|
val iconsTable = Table()
|
||||||
iconsTable.align(Align.center)
|
iconsTable.align(Align.center)
|
||||||
for (religionName in gameInfo.ruleSet.religions) {
|
for (religionName in gameInfo.ruleSet.religions) {
|
||||||
@ -74,25 +88,48 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
ImageGetter.getCircledReligionIcon(religionName, 60f),
|
ImageGetter.getCircledReligionIcon(religionName, 60f),
|
||||||
skin
|
skin
|
||||||
)
|
)
|
||||||
val translatedReligionName = religionName.tr()
|
|
||||||
button.onClick {
|
button.onClick {
|
||||||
if (previouslySelectedIcon != null) {
|
if (previouslySelectedIcon != null) {
|
||||||
previouslySelectedIcon!!.enable()
|
previouslySelectedIcon!!.enable()
|
||||||
}
|
}
|
||||||
iconName = religionName
|
|
||||||
this.religionName = religionName
|
|
||||||
previouslySelectedIcon = button
|
previouslySelectedIcon = button
|
||||||
button.disable()
|
button.disable()
|
||||||
descriptionLabel.setText(translatedReligionName)
|
|
||||||
rightSideButton.label = "Found [$translatedReligionName]".toLabel()
|
|
||||||
checkAndEnableRightSideButton()
|
checkAndEnableRightSideButton()
|
||||||
|
|
||||||
|
changeDisplayedReligionName(religionName)
|
||||||
|
this.religionName = religionName
|
||||||
|
changeReligionNameButton.enable()
|
||||||
}
|
}
|
||||||
if (religionName == this.religionName || gameInfo.religions.keys.any { it == religionName }) button.disable()
|
if (religionName == this.religionName || gameInfo.religions.keys.any { it == religionName }) button.disable()
|
||||||
iconsTable.add(button).pad(5f)
|
iconsTable.add(button).pad(5f)
|
||||||
}
|
}
|
||||||
iconsTable.row()
|
iconsTable.row()
|
||||||
topReligionIcons.add(iconsTable).padBottom(10f).row()
|
topReligionIcons.add(iconsTable).pad(5f).row()
|
||||||
topReligionIcons.add(descriptionLabel).center().padBottom(5f)
|
val labelTable = Table()
|
||||||
|
labelTable.add(descriptionLabel).pad(5f)
|
||||||
|
labelTable.add(changeReligionNameButton).pad(5f).row()
|
||||||
|
topReligionIcons.add(labelTable).center().pad(5f).row()
|
||||||
|
|
||||||
|
|
||||||
|
changeReligionNameButton.onClick {
|
||||||
|
AskTextPopup(
|
||||||
|
this,
|
||||||
|
label = "Choose a name for your religion",
|
||||||
|
icon = ImageGetter.getCircledReligionIcon(religionName!!, 80f),
|
||||||
|
defaultText = religionName!!,
|
||||||
|
actionOnOk = { religionName ->
|
||||||
|
if (religionName == Constants.noReligionName
|
||||||
|
|| gameInfo.ruleSet.religions.any { it == religionName }
|
||||||
|
|| gameInfo.religions.any { it.value.name == religionName }
|
||||||
|
) {
|
||||||
|
return@AskTextPopup false
|
||||||
|
}
|
||||||
|
changeDisplayedReligionName(religionName)
|
||||||
|
return@AskTextPopup true
|
||||||
|
}
|
||||||
|
).open()
|
||||||
|
}
|
||||||
|
changeReligionNameButton.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupVisibleReligionIcons() {
|
private fun setupVisibleReligionIcons() {
|
||||||
@ -178,7 +215,7 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
|
|
||||||
data class BeliefContainer(val pantheonBeliefCount: Int = 0, val founderBeliefCount: Int = 0, val followerBeliefCount: Int = 0, val enhancerBeliefCount: Int = 0) {
|
data class BeliefContainer(val pantheonBeliefCount: Int = 0, val founderBeliefCount: Int = 0, val followerBeliefCount: Int = 0, val enhancerBeliefCount: Int = 0) {
|
||||||
|
|
||||||
val chosenBeliefs: MutableList<Belief?> = MutableList(pantheonBeliefCount + founderBeliefCount + followerBeliefCount + enhancerBeliefCount) { null }
|
val chosenBeliefs: Array<Belief?> = Array(pantheonBeliefCount + founderBeliefCount + followerBeliefCount + enhancerBeliefCount) { null }
|
||||||
|
|
||||||
fun getBeliefTypeFromIndex(index: Int): BeliefType {
|
fun getBeliefTypeFromIndex(index: Int): BeliefType {
|
||||||
return when {
|
return when {
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.unciv.ui.pickerscreens
|
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
|
||||||
import com.unciv.logic.map.MapUnit
|
|
||||||
import com.unciv.ui.utils.*
|
|
||||||
|
|
||||||
class RenameUnitPopup(unit: MapUnit, screen: CameraStageBaseScreen): Popup(screen) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
val wrapper = Table()
|
|
||||||
wrapper.add(ImageGetter.getUnitIcon(unit.name).surroundWithCircle(80f)).padRight(10f)
|
|
||||||
wrapper.add("Choose name for [${unit.baseUnit.name}]".toLabel())
|
|
||||||
add(wrapper).colspan(2).row()
|
|
||||||
|
|
||||||
val nameField = TextField("", skin)
|
|
||||||
// Disallowed special characters - used by tr() or simply precaution
|
|
||||||
val illegalChars = "[]{}\"\\<>"
|
|
||||||
nameField.textFieldFilter = TextField.TextFieldFilter { _, char -> char !in illegalChars}
|
|
||||||
nameField.maxLength = unit.civInfo.gameInfo.ruleSet.units.values.maxOf { it.name.length }
|
|
||||||
add(nameField).growX().colspan(2).row()
|
|
||||||
addOKButton {
|
|
||||||
if (nameField.text != "" && nameField.text != unit.name) {
|
|
||||||
unit.instanceName = nameField.text
|
|
||||||
}
|
|
||||||
screen.game.setScreen(PromotionPickerScreen(unit))
|
|
||||||
}
|
|
||||||
addCloseButton()
|
|
||||||
equalizeLastTwoButtonWidths()
|
|
||||||
keyboardFocus = nameField
|
|
||||||
}
|
|
||||||
}
|
|
@ -255,7 +255,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
|
|
||||||
val cityReligion = city.religion.getMajorityReligion()
|
val cityReligion = city.religion.getMajorityReligion()
|
||||||
if (cityReligion != null) {
|
if (cityReligion != null) {
|
||||||
val religionImage = ImageGetter.getReligionImage(cityReligion.iconName)
|
val religionImage = ImageGetter.getReligionImage(cityReligion.getIconName())
|
||||||
iconTable.add(religionImage).size(20f).padLeft(5f).fillY()
|
iconTable.add(religionImage).size(20f).padLeft(5f).fillY()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
core/src/com/unciv/ui/utils/AskTextPopup.kt
Normal file
54
core/src/com/unciv/ui/utils/AskTextPopup.kt
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package com.unciv.ui.utils
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
||||||
|
|
||||||
|
/** Simple class for showing a prompt for a string to the user
|
||||||
|
* @param screen The previous screen the user was on
|
||||||
|
* @param label A line of text shown to the user
|
||||||
|
* @param icon Icon at the top, should have size 80f
|
||||||
|
* @param defaultText The text that should be in the prompt at the start
|
||||||
|
* @param errorText Text that will be shown when an error is detected
|
||||||
|
* @param maxLength The maximal amount of characters the user may input
|
||||||
|
* @param actionOnOk Lambda that will be executed after pressing 'OK'.
|
||||||
|
* Gets the text the user inputted as a parameter. Should return `true` if ready to close,
|
||||||
|
* `false` if `errorText` is to be displayed
|
||||||
|
*/
|
||||||
|
class AskTextPopup(
|
||||||
|
screen: CameraStageBaseScreen,
|
||||||
|
label: String = "Please enter some text",
|
||||||
|
icon: IconCircleGroup = ImageGetter.getImage("OtherIcons/Pencil").apply { this.color = Color.BLACK }.surroundWithCircle(80f),
|
||||||
|
defaultText: String = "",
|
||||||
|
errorText: String = "Invalid input! Please enter a different string.",
|
||||||
|
maxLength: Int = 32,
|
||||||
|
actionOnOk: (input: String) -> Boolean = { true },
|
||||||
|
) : Popup(screen) {
|
||||||
|
|
||||||
|
val illegalChars = "[]{}\"\\<>"
|
||||||
|
|
||||||
|
init {
|
||||||
|
val wrapper = Table()
|
||||||
|
wrapper.add(icon).padRight(10f)
|
||||||
|
wrapper.add(label.toLabel())
|
||||||
|
add(wrapper).colspan(2).row()
|
||||||
|
|
||||||
|
val nameField = TextField(defaultText, skin)
|
||||||
|
nameField.textFieldFilter = TextField.TextFieldFilter { _, char -> char !in illegalChars}
|
||||||
|
nameField.maxLength = maxLength
|
||||||
|
|
||||||
|
add(nameField).growX().colspan(2).row()
|
||||||
|
|
||||||
|
val errorLabel = errorText.toLabel()
|
||||||
|
errorLabel.color = Color.RED
|
||||||
|
|
||||||
|
addOKButton(automaticallyCloseOnPress = false) {
|
||||||
|
if (nameField.text == "" || !actionOnOk(nameField.text))
|
||||||
|
add(errorLabel).colspan(2).center()
|
||||||
|
else close()
|
||||||
|
}
|
||||||
|
addCloseButton()
|
||||||
|
equalizeLastTwoButtonWidths()
|
||||||
|
keyboardFocus = nameField
|
||||||
|
}
|
||||||
|
}
|
@ -142,18 +142,24 @@ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a [TextButton] that closes the popup, with [RETURN][KeyCharAndCode.RETURN] already mapped.
|
* Adds a [TextButton] that can close the popup, with [RETURN][KeyCharAndCode.RETURN] already mapped.
|
||||||
* @param text The button's caption, defaults to "OK".
|
* @param text The button's caption, defaults to "OK".
|
||||||
* @param additionalKey An additional key that should act like a click.
|
* @param additionalKey An additional key that should act like a click.
|
||||||
|
* @param automaticallyCloseOnPress Whether the popup should be closed when pressing this button.
|
||||||
* @param action A lambda to be executed after closing the popup when the button is clicked.
|
* @param action A lambda to be executed after closing the popup when the button is clicked.
|
||||||
* @return The new [Cell], NOT marked as end of row.
|
* @return The new [Cell], NOT marked as end of row.
|
||||||
*/
|
*/
|
||||||
fun addOKButton(
|
fun addOKButton(
|
||||||
text: String = Constants.OK,
|
text: String = Constants.OK,
|
||||||
additionalKey: KeyCharAndCode? = null,
|
additionalKey: KeyCharAndCode? = null,
|
||||||
action: (()->Unit)
|
automaticallyCloseOnPress: Boolean = true,
|
||||||
|
action: (()->Unit),
|
||||||
): Cell<TextButton> {
|
): Cell<TextButton> {
|
||||||
val okAction = { close(); action() }
|
val okAction = {
|
||||||
|
if (automaticallyCloseOnPress)
|
||||||
|
close()
|
||||||
|
action()
|
||||||
|
}
|
||||||
keyPressDispatcher[KeyCharAndCode.RETURN] = okAction
|
keyPressDispatcher[KeyCharAndCode.RETURN] = okAction
|
||||||
return addButtonInRow(text, additionalKey, okAction)
|
return addButtonInRow(text, additionalKey, okAction)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ open class YesNoPopup (
|
|||||||
init {
|
init {
|
||||||
promptLabel.setAlignment(Align.center)
|
promptLabel.setAlignment(Align.center)
|
||||||
add(promptLabel).colspan(2).row()
|
add(promptLabel).colspan(2).row()
|
||||||
addOKButton(Constants.yes, KeyCharAndCode('y'), action)
|
addOKButton(Constants.yes, KeyCharAndCode('y'), action = action)
|
||||||
addCloseButton(Constants.no, KeyCharAndCode('n'), restoreDefault)
|
addCloseButton(Constants.no, KeyCharAndCode('n'), restoreDefault)
|
||||||
equalizeLastTwoButtonWidths()
|
equalizeLastTwoButtonWidths()
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam
|
|||||||
viewingCiv,
|
viewingCiv,
|
||||||
gameInfo,
|
gameInfo,
|
||||||
viewingCiv.religionManager.getBeliefsToChooseAtFounding(),
|
viewingCiv.religionManager.getBeliefsToChooseAtFounding(),
|
||||||
pickIcon = true
|
pickIconAndName = true
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,7 +731,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam
|
|||||||
viewingCiv,
|
viewingCiv,
|
||||||
gameInfo,
|
gameInfo,
|
||||||
viewingCiv.religionManager.getBeliefsToChooseAtEnhancing(),
|
viewingCiv.religionManager.getBeliefsToChooseAtEnhancing(),
|
||||||
pickIcon = false
|
pickIconAndName = false
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ object UnitActions {
|
|||||||
if (!unit.hasUnique("May enhance a religion")) return
|
if (!unit.hasUnique("May enhance a religion")) return
|
||||||
if (!unit.civInfo.religionManager.mayEnhanceReligionAtAll(unit)) return
|
if (!unit.civInfo.religionManager.mayEnhanceReligionAtAll(unit)) return
|
||||||
actionList += UnitAction(UnitActionType.EnhanceReligion,
|
actionList += UnitAction(UnitActionType.EnhanceReligion,
|
||||||
title = "Enhance [${unit.civInfo.religionManager.religion!!.name}]",
|
title = "Enhance [${unit.civInfo.religionManager.religion!!.displayName}]",
|
||||||
action = getEnhanceReligionAction(unit).takeIf { unit.civInfo.religionManager.mayEnhanceReligionNow(unit) }
|
action = getEnhanceReligionAction(unit).takeIf { unit.civInfo.religionManager.mayEnhanceReligionNow(unit) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -550,7 +550,7 @@ object UnitActions {
|
|||||||
&& it.religion != unit.religion
|
&& it.religion != unit.religion
|
||||||
}
|
}
|
||||||
actionList += UnitAction(UnitActionType.SpreadReligion,
|
actionList += UnitAction(UnitActionType.SpreadReligion,
|
||||||
title = "Spread [${unit.religion!!}]",
|
title = "Spread [${unit.getReligionDisplayName()!!}]",
|
||||||
action = {
|
action = {
|
||||||
val followersOfOtherReligions = city.religion.getFollowersOfOtherReligionsThan(unit.religion!!)
|
val followersOfOtherReligions = city.religion.getFollowersOfOtherReligionsThan(unit.religion!!)
|
||||||
for (unique in unit.getMatchingUniques("When spreading religion to a city, gain [] times the amount of followers of other religions as []")) {
|
for (unique in unit.getMatchingUniques("When spreading religion to a city, gain [] times the amount of followers of other religions as []")) {
|
||||||
|
@ -632,6 +632,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
|
|||||||
* [Hourglass](https://thenounproject.com/search/?q=hourglass&i=142268) by I Create Stuff for the 'Turn' icon
|
* [Hourglass](https://thenounproject.com/search/?q=hourglass&i=142268) by I Create Stuff for the 'Turn' icon
|
||||||
* [Shield](https://thenounproject.com/search/?q=shield&i=813568) by Gregor Cresnar for Religious Strength
|
* [Shield](https://thenounproject.com/search/?q=shield&i=813568) by Gregor Cresnar for Religious Strength
|
||||||
* [skill sword flame](https://thenounproject.com/term/skill-sword-flame/2360212/) by Maxicons) for Remove Heresy
|
* [skill sword flame](https://thenounproject.com/term/skill-sword-flame/2360212/) by Maxicons) for Remove Heresy
|
||||||
|
* [Pencil](https://thenounproject.com/search/?q=pencil&i=4195852) by Muhamad Aldi Maulana for Enter Text Prompt Button / Pencil
|
||||||
|
|
||||||
## Main menu
|
## Main menu
|
||||||
|
|
||||||
|
@ -48,12 +48,14 @@ class TranslationTests {
|
|||||||
fun allUnitActionsHaveTranslation() {
|
fun allUnitActionsHaveTranslation() {
|
||||||
val actions: MutableSet<String> = HashSet()
|
val actions: MutableSet<String> = HashSet()
|
||||||
for (action in UnitActionType.values()) {
|
for (action in UnitActionType.values()) {
|
||||||
actions.add( when(action) {
|
actions.add(
|
||||||
UnitActionType.Upgrade -> "Upgrade to [unitType] ([goldCost] gold)"
|
when(action) {
|
||||||
UnitActionType.Create -> "Create [improvement]"
|
UnitActionType.Upgrade -> "Upgrade to [unitType] ([goldCost] gold)"
|
||||||
UnitActionType.SpreadReligion -> "Spread [religionName]"
|
UnitActionType.Create -> "Create [improvement]"
|
||||||
else -> action.value
|
UnitActionType.SpreadReligion -> "Spread [religionName]"
|
||||||
})
|
else -> action.value
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
val allUnitActionsHaveTranslation = allStringAreTranslated(actions)
|
val allUnitActionsHaveTranslation = allStringAreTranslated(actions)
|
||||||
Assert.assertTrue("This test will only pass when there is a translation for all unit actions",
|
Assert.assertTrue("This test will only pass when there is a translation for all unit actions",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user