Update Pantheon chooser visuals (#6291)

This commit is contained in:
SomeTroglodyte
2022-03-08 13:18:44 +01:00
committed by GitHub
parent 6a6c5184ec
commit deafc96d82
2 changed files with 40 additions and 26 deletions

View File

@ -85,9 +85,7 @@ class ReligionManager {
fun isPickablePantheonBelief(belief: Belief): Boolean {
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
return (civInfo.gameInfo.civilizations.none { it.religionManager.religion?.followerBeliefs?.contains(belief.name) == true })
}
fun choosePantheonBelief(belief: Belief) {

View File

@ -1,20 +1,24 @@
package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.logic.GameInfo
import com.unciv.logic.civilization.CivilizationInfo
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.ImageGetter
import com.unciv.ui.utils.WrappableLabel
import com.unciv.ui.utils.disable
import com.unciv.ui.utils.enable
import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
class PantheonPickerScreen(choosingCiv: CivilizationInfo, gameInfo: GameInfo) : PickerScreen() {
private var chosenPantheon: Belief? = null
private var selectedPantheon: Belief? = null
private var selectedButton: Button? = null
init {
closeButton.isVisible = true
@ -22,28 +26,40 @@ class PantheonPickerScreen(choosingCiv: CivilizationInfo, gameInfo: GameInfo) :
rightSideButton.setText("Choose a pantheon".tr())
topTable.apply { defaults().pad(10f) }
topTable.defaults().pad(10f).fillX()
for (belief in gameInfo.ruleSet.beliefs.values) {
if (!choosingCiv.religionManager.isPickablePantheonBelief(belief)) continue
val beliefTable = Table(skin).apply { touchable = Touchable.enabled;
background =
// Ideally I want to this to be the darker blue we use for pressed buttons, but I suck at UI so I'll leave it like this.
if (belief == chosenPantheon) ImageGetter.getBackground(ImageGetter.getBlue())
else ImageGetter.getBackground(ImageGetter.getBlue())
if (belief.type != BeliefType.Pantheon) continue
val beliefButton = getBeliefButton(belief)
if (choosingCiv.religionManager.isPickablePantheonBelief(belief)) {
beliefButton.onClick {
selectedButton?.enable()
selectedButton = beliefButton
beliefButton.disable()
selectedPantheon = belief
pick("Follow [${belief.name}]".tr())
}
} else {
beliefButton.touchable = Touchable.disabled
beliefButton.color = Color(0x7F0000ff)
}
beliefTable.pad(10f)
beliefTable.add(belief.name.toLabel(fontSize = Constants.headingFontSize)).row()
beliefTable.add(belief.uniques.joinToString { it.tr() }.toLabel())
beliefTable.onClick {
chosenPantheon = belief
pick("Follow [${chosenPantheon!!.name}]".tr())
}
topTable.add(beliefTable).fillX().row()
topTable.add(beliefButton).row()
}
rightSideButton.onClick(UncivSound.Choir) {
choosingCiv.religionManager.choosePantheonBelief(chosenPantheon!!)
choosingCiv.religionManager.choosePantheonBelief(selectedPantheon!!)
UncivGame.Current.setWorldScreen()
dispose()
}
}
private fun getBeliefButton(belief: Belief): Button {
val labelWidth = stage.width * 0.9f - 52f
return Button(skin).apply {
val nameLabel = WrappableLabel(belief.name, labelWidth, fontSize = Constants.headingFontSize)
add(nameLabel.apply { wrap = true }).row()
val effectLabel = WrappableLabel(belief.uniques.joinToString("\n") { it.tr() }, labelWidth)
add(effectLabel.apply { wrap = true })
}
}
}