diff --git a/android/Images/ReligionIcons/Follower.png b/android/Images/ReligionIcons/Follower.png new file mode 100644 index 0000000000..77d3380a1d Binary files /dev/null and b/android/Images/ReligionIcons/Follower.png differ diff --git a/android/Images/ReligionIcons/Religion.png b/android/Images/ReligionIcons/Religion.png new file mode 100644 index 0000000000..7cde1f5791 Binary files /dev/null and b/android/Images/ReligionIcons/Religion.png differ diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 2d4f11b217..93ed1ca67e 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -945,6 +945,7 @@ Choose a pantheon = Found Religion = Found Pantheon = Follow [belief] = +Religions and Beliefs = # Terrains diff --git a/core/src/com/unciv/logic/civilization/ReligionManager.kt b/core/src/com/unciv/logic/civilization/ReligionManager.kt index e255609e60..32c2c6af89 100644 --- a/core/src/com/unciv/logic/civilization/ReligionManager.kt +++ b/core/src/com/unciv/logic/civilization/ReligionManager.kt @@ -3,6 +3,7 @@ package com.unciv.logic.civilization import com.unciv.logic.map.MapUnit import com.unciv.models.Religion import com.unciv.models.ruleset.Belief +import com.unciv.models.ruleset.BeliefType import kotlin.random.Random class ReligionManager { @@ -73,7 +74,7 @@ class ReligionManager { } fun isPickablePantheonBelief(belief: Belief): Boolean { - if (belief.type != "Pantheon") return false + if (belief.type != BeliefType.Pantheon) return false if (civInfo.gameInfo.civilizations.any { it.religionManager.religion != null && it.religionManager.religion!!.followerBeliefs.contains(belief.name)}) return false return true @@ -179,4 +180,4 @@ enum class ReligionState { Religion, EnhancingReligion, // Great prophet used, but religion has not yet been enhanced EnhancedReligion -} \ No newline at end of file +} diff --git a/core/src/com/unciv/models/Religion.kt b/core/src/com/unciv/models/Religion.kt index 99864f73bd..26c538e1f9 100644 --- a/core/src/com/unciv/models/Religion.kt +++ b/core/src/com/unciv/models/Religion.kt @@ -2,6 +2,7 @@ package com.unciv.models import com.unciv.logic.GameInfo import com.unciv.models.ruleset.Belief +import com.unciv.models.ruleset.BeliefType import com.unciv.models.ruleset.Unique import com.unciv.models.stats.INamed @@ -49,13 +50,13 @@ class Religion() : INamed { fun getPantheonBeliefs(): Sequence { return mapToExistingBeliefs(followerBeliefs) - .filter { it.type == "Pantheon" } + .filter { it.type == BeliefType.Pantheon } .asSequence() } fun getFollowerBeliefs(): Sequence { return mapToExistingBeliefs(followerBeliefs) - .filter { it.type == "Follower" } + .filter { it.type == BeliefType.Follower } .asSequence() } @@ -80,15 +81,16 @@ class Religion() : INamed { fun isMajorReligion(): Boolean { if ("" in followerBeliefs) return true // Temporary as a result of follower beliefs not yet being implemented - return founderBeliefs.isNotEmpty() && followerBeliefs.any { gameInfo.ruleSet.beliefs[it]!!.type == "Follower"} + return founderBeliefs.isNotEmpty() && followerBeliefs + .any { gameInfo.ruleSet.beliefs[it]!!.type == BeliefType.Follower} } fun hasPantheon(): Boolean { // Currently unused // Temporary as a result of follower beliefs not yet being implemented - return followerBeliefs.any { it != "" && gameInfo.ruleSet.beliefs[it]!!.type == "Pantheon" } + return followerBeliefs.any { it != "" && gameInfo.ruleSet.beliefs[it]!!.type == BeliefType.Pantheon } } fun hasBelief(belief: String): Boolean { return followerBeliefs.contains(belief) || founderBeliefs.contains(belief) } -} \ No newline at end of file +} diff --git a/core/src/com/unciv/models/ruleset/Belief.kt b/core/src/com/unciv/models/ruleset/Belief.kt index f6cfe4a98e..b668a18d21 100644 --- a/core/src/com/unciv/models/ruleset/Belief.kt +++ b/core/src/com/unciv/models/ruleset/Belief.kt @@ -1,11 +1,33 @@ package com.unciv.models.ruleset import com.unciv.models.stats.INamed +import com.unciv.ui.civilopedia.CivilopediaText +import com.unciv.ui.civilopedia.FormattedLine +import java.awt.Color import java.util.ArrayList -class Belief: INamed { +class Belief: INamed, CivilopediaText() { override var name: String = "" - var type: String = "" + var type: BeliefType = BeliefType.None var uniques = ArrayList() val uniqueObjects: List by lazy { uniques.map { Unique(it) } } + + override fun getCivilopediaTextHeader() = FormattedLine(name, icon="Belief/$name", header=2) + override fun replacesCivilopediaDescription() = true + override fun hasCivilopediaTextLines() = true + override fun getCivilopediaTextLines(ruleset: Ruleset): List { + val textList = ArrayList() + textList += FormattedLine("{Type}: $type", color=type.color ) + uniqueObjects.forEach { + textList += FormattedLine(it) + } + return textList + } +} + +enum class BeliefType(val color: String) { + None(""), + Pantheon("#44c6cc"), + Follower("#ccaa44"), + Founder("#c00000") } diff --git a/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt b/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt index 9babae818a..96c6152320 100644 --- a/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt +++ b/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt @@ -75,6 +75,13 @@ object CivilopediaImageGetters { if (terrain == null) null else terrainImage(terrain, ImageGetter.ruleset, size) } + val belief = { name: String, size: Float -> + // Kludge until we decide how exactly to show Religions + if (ImageGetter.imageExists("ReligionIcons/$name")) { + ImageGetter.getReligionIcon(name).surroundWithCircle(size, color = Color.BLACK) + } + else null + } } /** Enum used as keys for Civilopedia "pages" (categories). @@ -100,6 +107,7 @@ enum class CivilopediaCategories ( Policy ("Policies", true, CivilopediaImageGetters.policy ), Tutorial ("Tutorials", false, null ), Difficulty ("Difficulty levels", false, null ), + Belief("Religions and Beliefs", false, CivilopediaImageGetters.belief) ; companion object { diff --git a/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt b/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt index 199616cdba..b6087d25ee 100644 --- a/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/civilopedia/CivilopediaScreen.kt @@ -40,9 +40,10 @@ class CivilopediaScreen( val image: Actor? = null, val flavour: ICivilopediaText? = null, val y: Float = 0f, // coordinates of button cell used to scroll to entry - val height: Float = 0f + val height: Float = 0f, + val sortBy: Int = 0 // optional, enabling overriding alphabetical order ) { - fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, description, image, flavour, y, height) + fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, description, image, flavour, y, height, sortBy) } private val categoryToEntries = LinkedHashMap>() @@ -99,7 +100,10 @@ class CivilopediaScreen( var entries = categoryToEntries[category]!! if (category != CivilopediaCategories.Difficulty) // this is the only case where we need them in order // Alphabetical order of localized names, using system default locale - entries = entries.sortedWith(compareBy(Collator.getInstance(), { it.name.tr() })) + entries = entries.sortedWith( + compareBy{ it.sortBy } + .thenBy (Collator.getInstance(), { it.name.tr() }) + ) var currentY = -1f @@ -283,6 +287,26 @@ class CivilopediaScreen( ) } + if (!hideReligionItems) + categoryToEntries[CivilopediaCategories.Belief] = ( + ruleset.beliefs.values.asSequence() + .map { + CivilopediaEntry( + it.name, + "", + CivilopediaCategories.Belief.getImage?.invoke(it.type.name, imageSize), + (it as? ICivilopediaText).takeUnless { ct -> ct==null || ct.isCivilopediaTextEmpty() }, + sortBy = it.type.ordinal + ) + } + CivilopediaEntry( + "Religions", + "", + CivilopediaCategories.Belief.getImage?.invoke("Religion", imageSize), + getReligionText(), + sortBy = -1 + ) + ).toList() + val buttonTable = Table() buttonTable.pad(15f) buttonTable.defaults().pad(10f) @@ -341,6 +365,16 @@ class CivilopediaScreen( selectEntry(link, noScrollAnimation = true) } + private fun getReligionText(): ICivilopediaText { + val lines = ArrayList() + lines += FormattedLine("Religions", header=2, color="#e34a2b") + lines += FormattedLine(separator=true) + ruleset.religions.sortedWith(compareBy(Collator.getInstance(), { it.tr() })).forEach { + lines += FormattedLine(it, icon="Belief/$it") + } + return SimpleCivilopediaText(lines, true) + } + override fun resize(width: Int, height: Int) { if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) { game.setScreen(CivilopediaScreen(game.worldScreen.gameInfo.ruleSet, currentCategory, currentEntry)) diff --git a/core/src/com/unciv/ui/civilopedia/CivilopediaText.kt b/core/src/com/unciv/ui/civilopedia/CivilopediaText.kt index 2539ddc52a..7128074af7 100644 --- a/core/src/com/unciv/ui/civilopedia/CivilopediaText.kt +++ b/core/src/com/unciv/ui/civilopedia/CivilopediaText.kt @@ -153,6 +153,7 @@ class FormattedLine ( val ruleSet = UncivGame.Current.gameInfo.ruleSet // order these with the categories that should take precedence in case of name conflicts (e.g. Railroad) _last_ val allObjectMapsSequence = sequence { + yield(CivilopediaCategories.Belief to ruleSet.beliefs) yield(CivilopediaCategories.Difficulty to ruleSet.difficulties) yield(CivilopediaCategories.Promotion to ruleSet.unitPromotions) yield(CivilopediaCategories.Policy to ruleSet.policies) diff --git a/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt index 4329ffc980..ef0987be20 100644 --- a/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt @@ -9,6 +9,7 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.Religion import com.unciv.models.UncivSound import com.unciv.models.ruleset.Belief +import com.unciv.models.ruleset.BeliefType import com.unciv.models.translations.tr import com.unciv.ui.utils.* @@ -126,7 +127,7 @@ class FoundReligionPickerScreen ( rightBeliefsToChoose.clear() val availableBeliefs = gameInfo.ruleSet.beliefs.values .filter { - it.type == beliefType + it.type.name == beliefType && gameInfo.religions.values.none { religion -> religion.hasBelief(it.name) } @@ -135,8 +136,8 @@ class FoundReligionPickerScreen ( for (belief in availableBeliefs) { val beliefButton = convertBeliefToButton(belief) beliefButton.onClick { - if (beliefType == "Follower") chosenFollowerBeliefs[leftButtonIndex] = belief - else if (beliefType == "Founder") chosenFounderBeliefs[leftButtonIndex] = belief + if (beliefType == BeliefType.Follower.name) chosenFollowerBeliefs[leftButtonIndex] = belief + else if (beliefType == BeliefType.Founder.name) chosenFounderBeliefs[leftButtonIndex] = belief updateLeftTable() checkAndEnableRightSideButton() } @@ -146,7 +147,7 @@ class FoundReligionPickerScreen ( private fun convertBeliefToButton(belief: Belief): Button { val contentsTable = Table() - contentsTable.add(belief.type.toLabel()).row() + contentsTable.add(belief.type.name.toLabel()).row() contentsTable.add(belief.name.toLabel(fontSize = 24)).row() contentsTable.add(belief.uniques.joinToString().toLabel()) return Button(contentsTable, skin) @@ -157,4 +158,4 @@ class FoundReligionPickerScreen ( contentsTable.add("Choose a [$beliefType] belief!".toLabel()) return Button(contentsTable, skin) } -} \ No newline at end of file +} diff --git a/docs/Credits.md b/docs/Credits.md index ae4ee1c937..bd7c9aa1b1 100644 --- a/docs/Credits.md +++ b/docs/Credits.md @@ -562,6 +562,8 @@ Unless otherwise specified, all the following are from [the Noun Project](https: * [taoism](https://thenounproject.com/search/?q=Taoism&i=740812) by parkjisun for Taosim * [Buddhism](https://thenounproject.com/search/?q=buddhism&i=38764) by Julio Yanes for Buddhism * [Hinduism](https://thenounproject.com/search/?q=hinduism&i=20383) by Mugda Damle for Hinduism +* [praying](https://thenounproject.com/term/praying/740809/) by parkjisun for Religion (Civilopedia concept entry) +* [praying](https://thenounproject.com/term/praying/886367/) by Gan Khoon Lay for Follower ## Others