Religion overview improved (#6303)

* Improve handling of Religion PickerScreen with long lists

* Fix mouseover graying Labels bug

* Update Pantheon chooser visuals

* Some Color.lerp simplification

* Religion pickers - Merge common stuff of Pantheon and Religion Pickers

* Religion pickers - Linting

* Religion pickers - Move ReligionOverviewTable extra lines capability to Belief, Fix FormattedLine link+center

* Religion pickers - Belief Civilopedia linked description

* Religion overview tweaked

* Religion overview tweaked - patch1
This commit is contained in:
SomeTroglodyte
2022-03-13 21:43:40 +01:00
committed by GitHub
parent e4b0afb7e3
commit d8e9563a7c
5 changed files with 68 additions and 55 deletions

View File

@ -1189,14 +1189,15 @@ Holy city of: [religionName] = Heilige Stadt von: [religionName]
Pressure = Druck
# Religion overview screen
Religion Name: = Name der Religion
Religion Name: = Name der Religion:
Pantheon Name: = Name des Pantheon:
Founding Civ: = Gegründet von:
Holy City: = Heilige Stadt:
Cities following this religion: = Städte die dieser Religion folgen
Click an icon to see the stats of this religion = Klicke auf ein Icon, um die Statistiken dieser Religion anzuzeigen
Religion: Off = Religion: Ausgeschaltet
Religion: Off = Religion: Aus
Minimal Faith required for\nthe next [Great Prophet]: = Mindest-Glaubenspunkte für\nden nächsten [Great Prophet]:
Religions to be founded: = Zu gründende Religionen:
Religions to be founded: = Noch zu gründende Religionen:
Religious status: = Religions-Status:
None = Keine
@ -4351,7 +4352,7 @@ Follower = Anhänger
Asceticism = Askese
Cathedrals = Kathedralen
May buy [buildingFilter] buildings with [stat] [cityFilter] = Kann [buildingFilter] Gebäude mit [stat] [cityFilter] kaufen
May buy [buildingFilter] buildings with [stat] [cityFilter] = Kann mit [stat] [buildingFilter] kaufen [cityFilter]
Choral Music = Chormusik

View File

@ -1198,6 +1198,7 @@ Pressure =
# Religion overview screen
Religion Name: =
Pantheon Name: =
Founding Civ: =
Holy City: =
Cities following this religion: =

View File

@ -31,7 +31,7 @@ class Belief : RulesetObject() {
textList += FormattedLine()
}
if (type != BeliefType.None)
textList += FormattedLine("{Type}: $type", color = type.color, centered = withHeader)
textList += FormattedLine("{Type}: {$type}", color = type.color, centered = withHeader)
uniqueObjects.forEach {
if (!it.hasFlag(UniqueFlag.HiddenToUsers))
textList += FormattedLine(it)

View File

@ -13,7 +13,10 @@ import com.unciv.ui.utils.KeyPressDispatcher.Companion.keyboardAvailable
import com.unciv.ui.utils.UncivTooltip.Companion.addTooltip
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPage: String = "") : BaseScreen(){
class EmpireOverviewScreen(
private var viewingPlayer: CivilizationInfo,
defaultPage: String = ""
) : BaseScreen() {
private val topTable = Table().apply { defaults().pad(10f) }
private val centerTable = Table().apply { defaults().pad(5f) }
@ -38,7 +41,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
)
}
private fun addCategory(name:String, table:Table, disabled:Boolean=false) {
private fun addCategory(name: String, table: Table, disabled: Boolean = false) {
// Buttons now hold their old label plus optionally an indicator for the shortcut key.
// Implement this templated on UnitActionsTable.getUnitActionButton()
val iconAndKey = ButtonDecorations.keyIconMap[name] ?: return // category without decoration entry disappears
@ -119,14 +122,14 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
val civGroup = Table()
var labelText = civ.civName.tr()+afterCivNameText
var labelColor=Color.WHITE
val backgroundColor:Color
var labelColor = Color.WHITE
val backgroundColor: Color
if (civ.isDefeated()) {
civGroup.add(ImageGetter.getImage("OtherIcons/DisbandUnit")).size(30f)
backgroundColor = Color.LIGHT_GRAY
labelColor = Color.BLACK
} else if (currentPlayer==civ // game.viewEntireMapForDebug
} else if (currentPlayer == civ // || game.viewEntireMapForDebug
|| currentPlayer.knows(civ) || currentPlayer.isDefeated() || currentPlayer.victoryManager.hasWon()) {
civGroup.add(ImageGetter.getNationIndicator(civ.nation, 30f))
backgroundColor = civ.nation.getOuterColor()

View File

@ -1,7 +1,9 @@
package com.unciv.ui.overviewscreen
import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.logic.civilization.CivilizationInfo
@ -23,109 +25,108 @@ class ReligionOverviewTable(
val gameInfo = viewingPlayer.gameInfo
private val civStatsTable = Table(BaseScreen.skin)
private val religionsTable = Table(BaseScreen.skin)
private val topButtons = Table(BaseScreen.skin)
private val topButtonLabel = "Click an icon to see the stats of this religion".toLabel()
private val religionButtons = Table(BaseScreen.skin)
private val religionButtonLabel = "Click an icon to see the stats of this religion".toLabel()
private val statsTable = Table(BaseScreen.skin)
private val beliefsTable = Table(BaseScreen.skin)
private var selectedReligion: String? = null
init {
addCivSpecificStats(civStatsTable)
addReligionButtons()
defaults().pad(5f)
align(Align.top)
loadReligionButtons()
religionsTable.add(topButtons).pad(5f).row()
religionsTable.add(topButtonLabel).pad(5f)
religionsTable.addSeparator()
religionsTable.add(statsTable).pad(5f).row()
religionsTable.add(beliefsTable).pad(5f)
add(civStatsTable).top().left().padRight(25f)
add(religionsTable)
civStatsTable.defaults().left().pad(5f)
civStatsTable.addCivSpecificStats()
add(civStatsTable).row()
add(religionButtons).row()
add(religionButtonLabel)
addSeparator()
statsTable.defaults().left().pad(5f)
add(statsTable).row()
beliefsTable.defaults().padBottom(20f)
add(beliefsTable).pad(20f)
}
private fun addCivSpecificStats(statsTable: Table) {
private fun Table.addCivSpecificStats() {
if (viewingPlayer.religionManager.canGenerateProphet()) {
statsTable.add("Minimal Faith required for\nthe next [great prophet equivalent]:"
add("Minimal Faith required for\nthe next [great prophet equivalent]:"
.fillPlaceholders(viewingPlayer.religionManager.getGreatProphetEquivalent()!!)
.toLabel()
).left()
statsTable.add(
)
add(
(viewingPlayer.religionManager.faithForNextGreatProphet() + 1)
.toLabel()
).right().pad(5f).row()
).right().row()
}
statsTable.add("Religions to be founded:".toLabel()).left()
add("Religions to be founded:".toLabel())
val foundedReligions = viewingPlayer.gameInfo.civilizations.count { it.religionManager.religionState >= ReligionState.Religion }
statsTable.add((viewingPlayer.religionManager.amountOfFoundableReligions() - foundedReligions).toLabel()).right().pad(5f).row()
add((viewingPlayer.religionManager.amountOfFoundableReligions() - foundedReligions).toLabel()).right().row()
statsTable.add("Religious status:".toLabel()).left()
statsTable.add(viewingPlayer.religionManager.religionState.toString().toLabel()).right().pad(5f).row()
add("Religious status:".toLabel()).left()
add(viewingPlayer.religionManager.religionState.toString().toLabel()).right().row()
}
private fun addReligionButtons() {
topButtons.clear()
private fun loadReligionButtons() {
religionButtons.clear()
val existingReligions: List<Religion> = gameInfo.civilizations.mapNotNull { it.religionManager.religion }
for (religion in existingReligions) {
val button: Button
if (religion.isPantheon()) {
val image = if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
val image = if (religion.isPantheon()) {
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
ImageGetter.getNationIndicator(religion.getFounder().nation, 60f)
else
ImageGetter.getRandomNationIndicator(60f)
button = Button(image, BaseScreen.skin)
} else {
button = Button(
ImageGetter.getCircledReligionIcon(religion.getIconName(), 60f),
BaseScreen.skin
)
ImageGetter.getCircledReligionIcon(religion.getIconName(), 60f)
}
val button = Button(image, BaseScreen.skin)
button.onClick {
selectedReligion = religion.name
addReligionButtons()
loadReligionButtons()
loadReligion(religion)
}
if (selectedReligion == religion.name)
button.disable()
topButtons.add(button).pad(5f)
religionButtons.add(button).pad(5f)
}
}
private fun loadReligion(religion: Religion) {
statsTable.clear()
beliefsTable.clear()
topButtonLabel.setText(religion.getReligionDisplayName().tr())
religionButtonLabel.setText(religion.getReligionDisplayName().tr())
for (belief in religion.getAllBeliefsOrdered()) {
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
beliefsTable.add(createBeliefDescription(belief)).row()
}
statsTable.add("Religion Name:".toLabel()).left()
statsTable.add(religion.getReligionDisplayName().toLabel()).right().pad(5f).row()
statsTable.add("Founding Civ:".toLabel()).left()
statsTable.add((if (religion.isPantheon()) "Pantheon Name:" else "Religion Name:").toLabel())
statsTable.add(religion.getReligionDisplayName().toLabel()).right().row()
statsTable.add("Founding Civ:".toLabel())
val foundingCivName =
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
religion.foundingCivName
else Constants.unknownNationName
statsTable.add(foundingCivName.toLabel()).right().pad(5f).row()
statsTable.add(foundingCivName.toLabel()).right().row()
if (religion.isMajorReligion()) {
val holyCity = gameInfo.getCities().firstOrNull { it.religion.religionThisIsTheHolyCityOf == religion.name }
if (holyCity != null) {
statsTable.add("Holy City:".toLabel()).left()
statsTable.add("Holy City:".toLabel())
val cityName =
if (viewingPlayer.exploredTiles.contains(holyCity.getCenterTile().position))
holyCity.name
else Constants.unknownNationName
statsTable.add(cityName.toLabel()).right().pad(5f).row()
statsTable.add(cityName.toLabel()).right().row()
}
}
statsTable.add("Cities following this religion:".toLabel()).left()
statsTable.add(religion.getFounder().religionManager.numberOfCitiesFollowingThisReligion().toString()).right().pad(5f).row()
statsTable.add("Cities following this religion:".toLabel())
statsTable.add(religion.getFounder().religionManager.numberOfCitiesFollowingThisReligion().toLabel()).right().row()
val minWidth = max(statsTable.minWidth, beliefsTable.minWidth) + 5
@ -133,6 +134,13 @@ class ReligionOverviewTable(
for (cell in beliefsTable.cells) {
cell.minWidth(minWidth)
}
// If we're wider than the container set our ScrollPane to center us
(parent as? ScrollPane)?.apply {
layout()
scrollX = maxX / 2
updateVisualScroll()
}
}
private fun createBeliefDescription(belief: Belief) =