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 { fun isPickablePantheonBelief(belief: Belief): Boolean {
if (belief.type != BeliefType.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 (civInfo.gameInfo.civilizations.none { it.religionManager.religion?.followerBeliefs?.contains(belief.name) == true })
return false
return true
} }
fun choosePantheonBelief(belief: Belief) { fun choosePantheonBelief(belief: Belief) {

View File

@ -1,49 +1,65 @@
package com.unciv.ui.pickerscreens package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable 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.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
import com.unciv.models.UncivSound import com.unciv.models.UncivSound
import com.unciv.models.ruleset.Belief import com.unciv.models.ruleset.Belief
import com.unciv.models.ruleset.BeliefType
import com.unciv.models.translations.tr 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.onClick
import com.unciv.ui.utils.toLabel
class PantheonPickerScreen(choosingCiv: CivilizationInfo, gameInfo: GameInfo) : PickerScreen() { class PantheonPickerScreen(choosingCiv: CivilizationInfo, gameInfo: GameInfo) : PickerScreen() {
private var chosenPantheon: Belief? = null private var selectedPantheon: Belief? = null
private var selectedButton: Button? = null
init { init {
closeButton.isVisible = true closeButton.isVisible = true
setDefaultCloseAction() setDefaultCloseAction()
rightSideButton.setText("Choose a pantheon".tr()) rightSideButton.setText("Choose a pantheon".tr())
topTable.apply { defaults().pad(10f) } topTable.defaults().pad(10f).fillX()
for (belief in gameInfo.ruleSet.beliefs.values) { for (belief in gameInfo.ruleSet.beliefs.values) {
if (!choosingCiv.religionManager.isPickablePantheonBelief(belief)) continue if (belief.type != BeliefType.Pantheon) continue
val beliefTable = Table(skin).apply { touchable = Touchable.enabled; val beliefButton = getBeliefButton(belief)
background = if (choosingCiv.religionManager.isPickablePantheonBelief(belief)) {
// 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. beliefButton.onClick {
if (belief == chosenPantheon) ImageGetter.getBackground(ImageGetter.getBlue()) selectedButton?.enable()
else ImageGetter.getBackground(ImageGetter.getBlue()) selectedButton = beliefButton
beliefButton.disable()
selectedPantheon = belief
pick("Follow [${belief.name}]".tr())
}
} else {
beliefButton.touchable = Touchable.disabled
beliefButton.color = Color(0x7F0000ff)
} }
beliefTable.pad(10f) topTable.add(beliefButton).row()
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()
} }
rightSideButton.onClick(UncivSound.Choir) { rightSideButton.onClick(UncivSound.Choir) {
choosingCiv.religionManager.choosePantheonBelief(chosenPantheon!!) choosingCiv.religionManager.choosePantheonBelief(selectedPantheon!!)
UncivGame.Current.setWorldScreen() 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 })
} }
} }
} }