mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Civilopedia remove migration-only interface elements (#5150)
This commit is contained in:
parent
9c876ad84e
commit
ffdc289611
@ -17,8 +17,6 @@ class Belief : INamed, ICivilopediaText, IHasUniques {
|
|||||||
|
|
||||||
override fun makeLink() = "Belief/$name"
|
override fun makeLink() = "Belief/$name"
|
||||||
override fun getCivilopediaTextHeader() = FormattedLine(name, icon = makeLink(), header = 2, color = if (type == BeliefType.None) "#e34a2b" else "")
|
override fun getCivilopediaTextHeader() = FormattedLine(name, icon = makeLink(), header = 2, color = if (type == BeliefType.None) "#e34a2b" else "")
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun getSortGroup(ruleset: Ruleset) = type.ordinal
|
override fun getSortGroup(ruleset: Ruleset) = type.ordinal
|
||||||
override fun getIconName() = if (type == BeliefType.None) "Religion" else type.name
|
override fun getIconName() = if (type == BeliefType.None) "Religion" else type.name
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import com.unciv.ui.civilopedia.FormattedLine
|
|||||||
import com.unciv.ui.civilopedia.ICivilopediaText
|
import com.unciv.ui.civilopedia.ICivilopediaText
|
||||||
import com.unciv.ui.utils.Fonts
|
import com.unciv.ui.utils.Fonts
|
||||||
import com.unciv.ui.utils.toPercent
|
import com.unciv.ui.utils.toPercent
|
||||||
import java.util.*
|
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.collections.HashMap
|
import kotlin.collections.HashMap
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
|
|||||||
var cost: Int = 0
|
var cost: Int = 0
|
||||||
var maintenance = 0
|
var maintenance = 0
|
||||||
private var percentStatBonus: Stats? = null
|
private var percentStatBonus: Stats? = null
|
||||||
var specialistSlots: Counter<String>? = null
|
private var specialistSlots: Counter<String>? = null
|
||||||
fun newSpecialists(): Counter<String> {
|
fun newSpecialists(): Counter<String> {
|
||||||
if (specialistSlots == null) return Counter()
|
if (specialistSlots == null) return Counter()
|
||||||
// Could have old specialist values of "gold", "science" etc - change them to the new specialist names
|
// Could have old specialist values of "gold", "science" etc - change them to the new specialist names
|
||||||
@ -58,8 +57,6 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
|
|||||||
|
|
||||||
/** City can only be built if one of these resources is nearby - it must be improved! */
|
/** City can only be built if one of these resources is nearby - it must be improved! */
|
||||||
var requiredNearbyImprovedResources: List<String>? = null
|
var requiredNearbyImprovedResources: List<String>? = null
|
||||||
@Deprecated("As of 3.15.19, replace with 'Cannot be built with []' unique")
|
|
||||||
private var cannotBeBuiltWith: String? = null
|
|
||||||
var cityStrength = 0
|
var cityStrength = 0
|
||||||
var cityHealth = 0
|
var cityHealth = 0
|
||||||
var replaces: String? = null
|
var replaces: String? = null
|
||||||
@ -67,7 +64,7 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
|
|||||||
var quote: String = ""
|
var quote: String = ""
|
||||||
override var uniques = ArrayList<String>()
|
override var uniques = ArrayList<String>()
|
||||||
override val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
override val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||||
var replacementTextForUniques = ""
|
private var replacementTextForUniques = ""
|
||||||
|
|
||||||
override var civilopediaText = listOf<FormattedLine>()
|
override var civilopediaText = listOf<FormattedLine>()
|
||||||
|
|
||||||
@ -167,6 +164,7 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
|
|||||||
if (unique.params[2].toInt() <= city.religion.getFollowersOfMajorityReligion() && matchesFilter(unique.params[1]))
|
if (unique.params[2].toInt() <= city.religion.getFollowersOfMajorityReligion() && matchesFilter(unique.params[1]))
|
||||||
stats.add(unique.stats)
|
stats.add(unique.stats)
|
||||||
|
|
||||||
|
@Suppress("RemoveRedundantQualifierName") // make it clearer Building inherits Stats
|
||||||
for (unique in uniqueObjects)
|
for (unique in uniqueObjects)
|
||||||
if (unique.placeholderText == "[] with []" && civInfo.hasResource(unique.params[1])
|
if (unique.placeholderText == "[] with []" && civInfo.hasResource(unique.params[1])
|
||||||
&& Stats.isStats(unique.params[0]))
|
&& Stats.isStats(unique.params[0]))
|
||||||
@ -198,10 +196,7 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
|
|||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCivilopediaTextHeader() = FormattedLine(name, header=2, icon=makeLink())
|
|
||||||
override fun makeLink() = if (isAnyWonder()) "Wonder/$name" else "Building/$name"
|
override fun makeLink() = if (isAnyWonder()) "Wonder/$name" else "Building/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
fun Float.formatSignedInt() = (if (this > 0f) "+" else "") + this.toInt().toString()
|
fun Float.formatSignedInt() = (if (this > 0f) "+" else "") + this.toInt().toString()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.models.ruleset
|
package com.unciv.models.ruleset
|
||||||
|
|
||||||
import com.unciv.Constants
|
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
import com.unciv.ui.civilopedia.ICivilopediaText
|
import com.unciv.ui.civilopedia.ICivilopediaText
|
||||||
import com.unciv.ui.civilopedia.FormattedLine
|
import com.unciv.ui.civilopedia.FormattedLine
|
||||||
@ -33,7 +32,7 @@ class Difficulty: INamed, ICivilopediaText {
|
|||||||
var aiUnhappinessModifier = 1f
|
var aiUnhappinessModifier = 1f
|
||||||
var turnBarbariansCanEnterPlayerTiles = 0
|
var turnBarbariansCanEnterPlayerTiles = 0
|
||||||
var clearBarbarianCampReward = 25
|
var clearBarbarianCampReward = 25
|
||||||
|
|
||||||
// property defined in json but so far unused:
|
// property defined in json but so far unused:
|
||||||
// var aisExchangeTechs = false
|
// var aisExchangeTechs = false
|
||||||
|
|
||||||
@ -41,8 +40,6 @@ class Difficulty: INamed, ICivilopediaText {
|
|||||||
|
|
||||||
|
|
||||||
override fun makeLink() = "Difficulty/$name"
|
override fun makeLink() = "Difficulty/$name"
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
|
|
||||||
private fun Float.toPercent() = (this * 100).toInt()
|
private fun Float.toPercent() = (this * 100).toInt()
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
|
@ -194,8 +194,6 @@ class Nation : INamed, ICivilopediaText, IHasUniques {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Nation/$name"
|
override fun makeLink() = "Nation/$name"
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun getSortGroup(ruleset: Ruleset) = when {
|
override fun getSortGroup(ruleset: Ruleset) = when {
|
||||||
isCityState() -> 1
|
isCityState() -> 1
|
||||||
isBarbarian() -> 9
|
isBarbarian() -> 9
|
||||||
|
@ -51,8 +51,6 @@ open class Policy : INamed, IHasUniques, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Policy/$name"
|
override fun makeLink() = "Policy/$name"
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun getSortGroup(ruleset: Ruleset) =
|
override fun getSortGroup(ruleset: Ruleset) =
|
||||||
ruleset.eras[branch.era]!!.eraNumber * 10000 +
|
ruleset.eras[branch.era]!!.eraNumber * 10000 +
|
||||||
ruleset.policyBranches.keys.indexOf(branch.name) * 100 +
|
ruleset.policyBranches.keys.indexOf(branch.name) * 100 +
|
||||||
|
@ -144,8 +144,6 @@ class Technology: INamed, ICivilopediaText, IHasUniques {
|
|||||||
|
|
||||||
|
|
||||||
override fun makeLink() = "Technology/$name"
|
override fun makeLink() = "Technology/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
val lineList = ArrayList<FormattedLine>()
|
val lineList = ArrayList<FormattedLine>()
|
||||||
|
@ -62,8 +62,6 @@ class Terrain : NamedStats(), ICivilopediaText, IHasUniques {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Terrain/$name"
|
override fun makeLink() = "Terrain/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
//todo where should we explain Rivers?
|
//todo where should we explain Rivers?
|
||||||
|
@ -101,8 +101,6 @@ class TileImprovement : NamedStats(), ICivilopediaText, IHasUniques {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Improvement/$name"
|
override fun makeLink() = "Improvement/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
val textList = ArrayList<FormattedLine>()
|
val textList = ArrayList<FormattedLine>()
|
||||||
|
@ -22,8 +22,6 @@ class TileResource : NamedStats(), ICivilopediaText {
|
|||||||
|
|
||||||
|
|
||||||
override fun makeLink() = "Resource/$name"
|
override fun makeLink() = "Resource/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
val textList = ArrayList<FormattedLine>()
|
val textList = ArrayList<FormattedLine>()
|
||||||
|
@ -38,10 +38,10 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
lateinit var unitType: String
|
lateinit var unitType: String
|
||||||
fun getType() = ruleset.unitTypes[unitType]!!
|
fun getType() = ruleset.unitTypes[unitType]!!
|
||||||
var requiredTech: String? = null
|
var requiredTech: String? = null
|
||||||
var requiredResource: String? = null
|
private var requiredResource: String? = null
|
||||||
override var uniques = ArrayList<String>() // Can not be a hashset as that would remove doubles
|
override var uniques = ArrayList<String>() // Can not be a hashset as that would remove doubles
|
||||||
override val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
override val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||||
var replacementTextForUniques = ""
|
private var replacementTextForUniques = ""
|
||||||
var promotions = HashSet<String>()
|
var promotions = HashSet<String>()
|
||||||
var obsoleteTech: String? = null
|
var obsoleteTech: String? = null
|
||||||
var upgradesTo: String? = null
|
var upgradesTo: String? = null
|
||||||
@ -105,8 +105,6 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Unit/$name"
|
override fun makeLink() = "Unit/$name"
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
val textList = ArrayList<FormattedLine>()
|
val textList = ArrayList<FormattedLine>()
|
||||||
@ -323,27 +321,23 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
return rejectionReasons
|
return rejectionReasons
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param ignoreTechPolicyRequirements: its `true` value is used when upgrading via ancient ruins,
|
|
||||||
* as there we don't care whether we have the required tech, policy or building for the unit,
|
|
||||||
* but do still care whether we have the resources required for the unit
|
|
||||||
*/
|
|
||||||
fun getRejectionReasons(civInfo: CivilizationInfo): RejectionReasons {
|
fun getRejectionReasons(civInfo: CivilizationInfo): RejectionReasons {
|
||||||
val rejectionReasons = RejectionReasons()
|
val rejectionReasons = RejectionReasons()
|
||||||
val ruleSet = civInfo.gameInfo.ruleSet
|
val ruleSet = civInfo.gameInfo.ruleSet
|
||||||
|
|
||||||
if (uniques.contains("Unbuildable"))
|
if (uniques.contains("Unbuildable"))
|
||||||
rejectionReasons.add(RejectionReason.Unbuildable)
|
rejectionReasons.add(RejectionReason.Unbuildable)
|
||||||
|
|
||||||
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!))
|
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!))
|
||||||
rejectionReasons.add(RejectionReason.RequiresTech.apply { this.errorMessage = "$requiredTech not researched" })
|
rejectionReasons.add(RejectionReason.RequiresTech.apply { this.errorMessage = "$requiredTech not researched" })
|
||||||
if (obsoleteTech != null && civInfo.tech.isResearched(obsoleteTech!!))
|
if (obsoleteTech != null && civInfo.tech.isResearched(obsoleteTech!!))
|
||||||
rejectionReasons.add(RejectionReason.Obsoleted.apply { this.errorMessage = "Obsolete by $obsoleteTech" })
|
rejectionReasons.add(RejectionReason.Obsoleted.apply { this.errorMessage = "Obsolete by $obsoleteTech" })
|
||||||
|
|
||||||
if (uniqueTo != null && uniqueTo != civInfo.civName)
|
if (uniqueTo != null && uniqueTo != civInfo.civName)
|
||||||
rejectionReasons.add(RejectionReason.UniqueToOtherNation.apply { this.errorMessage = "Unique to $uniqueTo" })
|
rejectionReasons.add(RejectionReason.UniqueToOtherNation.apply { this.errorMessage = "Unique to $uniqueTo" })
|
||||||
if (ruleSet.units.values.any { it.uniqueTo == civInfo.civName && it.replaces == name })
|
if (ruleSet.units.values.any { it.uniqueTo == civInfo.civName && it.replaces == name })
|
||||||
rejectionReasons.add(RejectionReason.ReplacedByOurUnique.apply { this.errorMessage = "Our unique unit replaces this" })
|
rejectionReasons.add(RejectionReason.ReplacedByOurUnique.apply { this.errorMessage = "Our unique unit replaces this" })
|
||||||
|
|
||||||
if (!civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled && isNuclearWeapon())
|
if (!civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled && isNuclearWeapon())
|
||||||
rejectionReasons.add(RejectionReason.DisabledBySetting)
|
rejectionReasons.add(RejectionReason.DisabledBySetting)
|
||||||
|
|
||||||
@ -372,7 +366,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
errorMessage = "Consumes [$amount] [$resource]"
|
errorMessage = "Consumes [$amount] [$resource]"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uniques.contains(Constants.settlerUnique) &&
|
if (uniques.contains(Constants.settlerUnique) &&
|
||||||
(civInfo.isCityState() || civInfo.isOneCityChallenger())
|
(civInfo.isCityState() || civInfo.isOneCityChallenger())
|
||||||
)
|
)
|
||||||
@ -385,7 +379,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
override fun isBuildable(cityConstructions: CityConstructions): Boolean {
|
override fun isBuildable(cityConstructions: CityConstructions): Boolean {
|
||||||
return getRejectionReasons(cityConstructions).isEmpty()
|
return getRejectionReasons(cityConstructions).isEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBuildableIgnoringTechs(civInfo: CivilizationInfo): Boolean {
|
fun isBuildableIgnoringTechs(civInfo: CivilizationInfo): Boolean {
|
||||||
val rejectionReasons = getRejectionReasons(civInfo)
|
val rejectionReasons = getRejectionReasons(civInfo)
|
||||||
return rejectionReasons.filterTechPolicyEraWonderRequirements().isEmpty()
|
return rejectionReasons.filterTechPolicyEraWonderRequirements().isEmpty()
|
||||||
|
@ -46,8 +46,6 @@ class Promotion : INamed, ICivilopediaText, IHasUniques {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeLink() = "Promotion/$name"
|
override fun makeLink() = "Promotion/$name"
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = true
|
|
||||||
|
|
||||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||||
val textList = ArrayList<FormattedLine>()
|
val textList = ArrayList<FormattedLine>()
|
||||||
|
@ -6,10 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.ruleset.Belief
|
import com.unciv.models.ruleset.*
|
||||||
import com.unciv.models.ruleset.Ruleset
|
|
||||||
import com.unciv.models.ruleset.Unique
|
|
||||||
import com.unciv.models.ruleset.VictoryType
|
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
@ -29,7 +26,6 @@ class CivilopediaScreen(
|
|||||||
|
|
||||||
/** Container collecting data per Civilopedia entry
|
/** Container collecting data per Civilopedia entry
|
||||||
* @param name From [Ruleset] object [INamed.name]
|
* @param name From [Ruleset] object [INamed.name]
|
||||||
* @param description Multiline text
|
|
||||||
* @param image Icon for button
|
* @param image Icon for button
|
||||||
* @param flavour [ICivilopediaText]
|
* @param flavour [ICivilopediaText]
|
||||||
* @param y Y coordinate for scrolling to
|
* @param y Y coordinate for scrolling to
|
||||||
@ -37,14 +33,13 @@ class CivilopediaScreen(
|
|||||||
*/
|
*/
|
||||||
private class CivilopediaEntry (
|
private class CivilopediaEntry (
|
||||||
val name: String,
|
val name: String,
|
||||||
val description: String,
|
|
||||||
val image: Actor? = null,
|
val image: Actor? = null,
|
||||||
val flavour: ICivilopediaText? = null,
|
val flavour: ICivilopediaText? = null,
|
||||||
val y: Float = 0f, // coordinates of button cell used to scroll to entry
|
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
|
val sortBy: Int = 0 // optional, enabling overriding alphabetical order
|
||||||
) {
|
) {
|
||||||
fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, description, image, flavour, y, height, sortBy)
|
fun withCoordinates(y: Float, height: Float) = CivilopediaEntry(name, image, flavour, y, height, sortBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val categoryToEntries = LinkedHashMap<CivilopediaCategories, Collection<CivilopediaEntry>>()
|
private val categoryToEntries = LinkedHashMap<CivilopediaCategories, Collection<CivilopediaEntry>>()
|
||||||
@ -53,7 +48,6 @@ class CivilopediaScreen(
|
|||||||
|
|
||||||
private val entrySelectTable = Table().apply { defaults().pad(6f).left() }
|
private val entrySelectTable = Table().apply { defaults().pad(6f).left() }
|
||||||
private val entrySelectScroll: ScrollPane
|
private val entrySelectScroll: ScrollPane
|
||||||
private val descriptionLabel = "".toLabel()
|
|
||||||
private val flavourTable = Table()
|
private val flavourTable = Table()
|
||||||
|
|
||||||
private var currentCategory: CivilopediaCategories = CivilopediaCategories.Tutorial
|
private var currentCategory: CivilopediaCategories = CivilopediaCategories.Tutorial
|
||||||
@ -90,7 +84,6 @@ class CivilopediaScreen(
|
|||||||
currentCategory = category
|
currentCategory = category
|
||||||
entrySelectTable.clear()
|
entrySelectTable.clear()
|
||||||
entryIndex.clear()
|
entryIndex.clear()
|
||||||
descriptionLabel.setText("")
|
|
||||||
flavourTable.clear()
|
flavourTable.clear()
|
||||||
|
|
||||||
for (button in categoryToButtons.values) button.color = Color.WHITE
|
for (button in categoryToButtons.values) button.color = Color.WHITE
|
||||||
@ -147,13 +140,6 @@ class CivilopediaScreen(
|
|||||||
}
|
}
|
||||||
private fun selectEntry(entry: CivilopediaEntry) {
|
private fun selectEntry(entry: CivilopediaEntry) {
|
||||||
currentEntry = entry.name
|
currentEntry = entry.name
|
||||||
if(entry.flavour != null && entry.flavour.replacesCivilopediaDescription()) {
|
|
||||||
descriptionLabel.setText("")
|
|
||||||
descriptionLabel.isVisible = false
|
|
||||||
} else {
|
|
||||||
descriptionLabel.setText(entry.description)
|
|
||||||
descriptionLabel.isVisible = true
|
|
||||||
}
|
|
||||||
flavourTable.clear()
|
flavourTable.clear()
|
||||||
if (entry.flavour != null) {
|
if (entry.flavour != null) {
|
||||||
flavourTable.isVisible = true
|
flavourTable.isVisible = true
|
||||||
@ -207,11 +193,11 @@ class CivilopediaScreen(
|
|||||||
if (hideReligionItems && loopCategory == CivilopediaCategories.Belief) continue
|
if (hideReligionItems && loopCategory == CivilopediaCategories.Belief) continue
|
||||||
categoryToEntries[loopCategory] =
|
categoryToEntries[loopCategory] =
|
||||||
getCategoryIterator(loopCategory)
|
getCategoryIterator(loopCategory)
|
||||||
.filter { it.getUniquesAsObjects()?.let { uniques -> shouldBeDisplayed(uniques) } ?: true }
|
.filter { (it as? IHasUniques)?.let { obj -> shouldBeDisplayed(obj.uniqueObjects) } ?: true }
|
||||||
.map { CivilopediaEntry(
|
.map { CivilopediaEntry(
|
||||||
(it as INamed).name, "",
|
(it as INamed).name,
|
||||||
loopCategory.getImage?.invoke(it.getIconName(), imageSize),
|
loopCategory.getImage?.invoke(it.getIconName(), imageSize),
|
||||||
it.takeUnless { ct -> ct.isCivilopediaTextEmpty() },
|
flavour = it,
|
||||||
sortBy = it.getSortGroup(ruleset)
|
sortBy = it.getSortGroup(ruleset)
|
||||||
) }
|
) }
|
||||||
}
|
}
|
||||||
@ -257,8 +243,6 @@ class CivilopediaScreen(
|
|||||||
entrySelectScroll.setOverscroll(false, false)
|
entrySelectScroll.setOverscroll(false, false)
|
||||||
val descriptionTable = Table()
|
val descriptionTable = Table()
|
||||||
descriptionTable.add(flavourTable).row()
|
descriptionTable.add(flavourTable).row()
|
||||||
descriptionLabel.wrap = true // requires explicit cell width!
|
|
||||||
descriptionTable.add(descriptionLabel).width(stage.width * 0.5f).padTop(10f).row()
|
|
||||||
val entrySplitPane = SplitPane(entrySelectScroll, ScrollPane(descriptionTable), false, skin)
|
val entrySplitPane = SplitPane(entrySelectScroll, ScrollPane(descriptionTable), false, skin)
|
||||||
entrySplitPane.splitAmount = 0.3f
|
entrySplitPane.splitAmount = 0.3f
|
||||||
entryTable.addActor(entrySplitPane)
|
entryTable.addActor(entrySplitPane)
|
||||||
|
@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.metadata.BaseRuleset
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.ruleset.IHasUniques
|
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
@ -381,16 +380,13 @@ object MarkupRenderer {
|
|||||||
|
|
||||||
/** Storage class for instantiation of the simplest form containing only the lines collection */
|
/** Storage class for instantiation of the simplest form containing only the lines collection */
|
||||||
open class SimpleCivilopediaText(
|
open class SimpleCivilopediaText(
|
||||||
override var civilopediaText: List<FormattedLine>,
|
override var civilopediaText: List<FormattedLine>
|
||||||
val isComplete: Boolean = false
|
|
||||||
) : ICivilopediaText {
|
) : ICivilopediaText {
|
||||||
constructor(strings: Sequence<String>, isComplete: Boolean = false) : this(
|
constructor(strings: Sequence<String>) : this(
|
||||||
strings.map { FormattedLine(it) }.toList(), isComplete)
|
strings.map { FormattedLine(it) }.toList())
|
||||||
constructor(first: Sequence<FormattedLine>, strings: Sequence<String>, isComplete: Boolean = false) : this(
|
constructor(first: Sequence<FormattedLine>, strings: Sequence<String>) : this(
|
||||||
(first + strings.map { FormattedLine(it) }).toList(), isComplete)
|
(first + strings.map { FormattedLine(it) }).toList())
|
||||||
|
|
||||||
override fun hasCivilopediaTextLines() = true
|
|
||||||
override fun replacesCivilopediaDescription() = isComplete
|
|
||||||
override fun makeLink() = ""
|
override fun makeLink() = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,13 +424,6 @@ interface ICivilopediaText {
|
|||||||
*/
|
*/
|
||||||
fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> = listOf()
|
fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> = listOf()
|
||||||
|
|
||||||
/** Override this and return true to tell the Civilopedia that the legacy description is no longer needed */
|
|
||||||
fun replacesCivilopediaDescription() = false
|
|
||||||
/** Override this and return true to tell the Civilopedia that this is not empty even if nothing came from json */
|
|
||||||
fun hasCivilopediaTextLines() = false
|
|
||||||
/** Indicates that neither json nor getCivilopediaTextLines have content */
|
|
||||||
fun isCivilopediaTextEmpty() = civilopediaText.isEmpty() && !hasCivilopediaTextLines()
|
|
||||||
|
|
||||||
/** Build a Gdx [Table] showing our [formatted][FormattedLine] [content][civilopediaText]. */
|
/** Build a Gdx [Table] showing our [formatted][FormattedLine] [content][civilopediaText]. */
|
||||||
fun renderCivilopediaText (labelWidth: Float, linkAction: ((id: String)->Unit)? = null): Table {
|
fun renderCivilopediaText (labelWidth: Float, linkAction: ((id: String)->Unit)? = null): Table {
|
||||||
return MarkupRenderer.render(civilopediaText, labelWidth, linkAction = linkAction)
|
return MarkupRenderer.render(civilopediaText, labelWidth, linkAction = linkAction)
|
||||||
@ -461,32 +450,24 @@ interface ICivilopediaText {
|
|||||||
val next = outerLines.next()
|
val next = outerLines.next()
|
||||||
if (!middleDone && !next.isEmpty() && next.linkType != FormattedLine.LinkType.None) {
|
if (!middleDone && !next.isEmpty() && next.linkType != FormattedLine.LinkType.None) {
|
||||||
middleDone = true
|
middleDone = true
|
||||||
if (hasCivilopediaTextLines()) {
|
if (outerNotEmpty) yield(FormattedLine())
|
||||||
if (outerNotEmpty) yield(FormattedLine())
|
yieldAll(getCivilopediaTextLines(ruleset))
|
||||||
yieldAll(getCivilopediaTextLines(ruleset))
|
yield(FormattedLine())
|
||||||
yield(FormattedLine())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
outerNotEmpty = true
|
outerNotEmpty = true
|
||||||
yield(next)
|
yield(next)
|
||||||
}
|
}
|
||||||
if (!middleDone) {
|
if (!middleDone) {
|
||||||
if (outerNotEmpty && hasCivilopediaTextLines()) yield(FormattedLine())
|
if (outerNotEmpty) yield(FormattedLine())
|
||||||
yieldAll(getCivilopediaTextLines(ruleset))
|
yieldAll(getCivilopediaTextLines(ruleset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SimpleCivilopediaText(newLines.toList(), isComplete = true)
|
return SimpleCivilopediaText(newLines.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create the correct string for a Civilopedia link */
|
/** Create the correct string for a Civilopedia link */
|
||||||
fun makeLink(): String
|
fun makeLink(): String
|
||||||
|
|
||||||
/** This just marshals access to the uniques so they can be queried as part of the ICivilopediaText interface.
|
|
||||||
* Used exclusively by CivilopediaScreen, named to avoid JVM signature confusion
|
|
||||||
* (a getUniqueObjects exists in IHasUniques and most civilopedia objects will implement that interface)
|
|
||||||
*/
|
|
||||||
fun getUniquesAsObjects() = (this as? IHasUniques)?.uniqueObjects
|
|
||||||
|
|
||||||
/** Overrides alphabetical sorting in Civilopedia
|
/** Overrides alphabetical sorting in Civilopedia
|
||||||
* @param ruleset The current ruleset in case the function needs to do lookups
|
* @param ruleset The current ruleset in case the function needs to do lookups
|
||||||
*/
|
*/
|
||||||
|
@ -62,8 +62,7 @@ class TutorialController(screen: CameraStageBaseScreen) {
|
|||||||
lines: Array<String>
|
lines: Array<String>
|
||||||
) : INamed, SimpleCivilopediaText(
|
) : INamed, SimpleCivilopediaText(
|
||||||
sequenceOf(FormattedLine(extraImage = rawName)),
|
sequenceOf(FormattedLine(extraImage = rawName)),
|
||||||
lines.asSequence(),
|
lines.asSequence()
|
||||||
true
|
|
||||||
) {
|
) {
|
||||||
override var name = rawName.replace("_", " ")
|
override var name = rawName.replace("_", " ")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user