Clarify relation Oil well / Refrigeration a little (#5570)

This commit is contained in:
SomeTroglodyte 2021-10-27 19:08:04 +02:00 committed by GitHub
parent ca1d070c81
commit 21d2f7b714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 4 deletions

View File

@ -92,6 +92,10 @@ class Technology: RulesetObject() {
if (tileImprovements.isNotEmpty()) if (tileImprovements.isNotEmpty())
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() } lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
val seeAlsoObjects = getSeeAlsoObjects(ruleset)
if (seeAlsoObjects.any())
lineList += "{See also}: " + seeAlsoObjects.joinToString { it.name }
return lineList.joinToString("\n") { it.tr() } return lineList.joinToString("\n") { it.tr() }
} }
@ -110,7 +114,7 @@ class Technology: RulesetObject() {
// Used for Civilopedia, Alert and Picker, so if any of these decide to ignore the "Will not be displayed in Civilopedia" unique this needs refactoring // Used for Civilopedia, Alert and Picker, so if any of these decide to ignore the "Will not be displayed in Civilopedia" unique this needs refactoring
fun getObsoletedBuildings(civInfo: CivilizationInfo) = getFilteredBuildings(civInfo) fun getObsoletedBuildings(civInfo: CivilizationInfo) = getFilteredBuildings(civInfo)
{ it.uniqueObjects.any { unique -> unique.placeholderText == "Obsolete with []" && unique.params[0] == name } } { it.uniqueObjects.any { unique -> unique.placeholderText == "Obsolete with []" && unique.params[0] == name } }
// Helper: common filtering for both getEnabledBuildings and getObsoletedBuildings, difference via predicate parameter // Helper: common filtering for both getEnabledBuildings and getObsoletedBuildings, difference via predicate parameter
private fun getFilteredBuildings(civInfo: CivilizationInfo, predicate: (Building)->Boolean): Sequence<Building> { private fun getFilteredBuildings(civInfo: CivilizationInfo, predicate: (Building)->Boolean): Sequence<Building> {
val nuclearWeaponsEnabled = civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled val nuclearWeaponsEnabled = civInfo.gameInfo.gameParameters.nuclearWeaponsEnabled
@ -145,6 +149,17 @@ class Technology: RulesetObject() {
} }
} }
/** Get improvements related to this tech by a unique */
private fun getSeeAlsoObjects(ruleset: Ruleset) =
// This is a band-aid to clarify the relation Offshore platform - Refrigeration. A generic variant
// covering all mentions in uniques in all ruleset objects would be possible here but - overkill for now.
ruleset.tileImprovements.values.asSequence()
.filter { improvement ->
improvement.getMatchingUniques(UniqueType.RequiresTechToBuildOnTile).any {
it.params[1] == name
}
}
override fun makeLink() = "Technology/$name" override fun makeLink() = "Technology/$name"
@ -180,7 +195,7 @@ class Technology: RulesetObject() {
} }
} }
} }
if (uniques.isNotEmpty()) { if (uniques.isNotEmpty()) {
lineList += FormattedLine() lineList += FormattedLine()
for (unique in uniqueObjects) lineList += FormattedLine(unique) for (unique in uniqueObjects) lineList += FormattedLine(unique)
@ -263,6 +278,15 @@ class Technology: RulesetObject() {
} }
} }
val seeAlsoObjects = getSeeAlsoObjects(ruleset)
if (seeAlsoObjects.any()) {
lineList += FormattedLine()
lineList += FormattedLine("{See also}:")
seeAlsoObjects.forEach {
lineList += FormattedLine(it.name, link = it.makeLink())
}
}
return lineList return lineList
} }
} }

View File

@ -12,12 +12,18 @@ import com.unciv.logic.civilization.TechManager
import com.unciv.models.UncivSound import com.unciv.models.UncivSound
import com.unciv.models.ruleset.tech.Technology import com.unciv.models.ruleset.tech.Technology
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.civilopedia.CivilopediaCategories
import com.unciv.ui.civilopedia.CivilopediaScreen
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null, private val freeTechPick: Boolean = false) : PickerScreen() { class TechPickerScreen(
internal val civInfo: CivilizationInfo,
centerOnTech: Technology? = null,
private val freeTechPick: Boolean = false
) : PickerScreen() {
private var techNameToButton = HashMap<String, TechButton>() private var techNameToButton = HashMap<String, TechButton>()
private var selectedTech: Technology? = null private var selectedTech: Technology? = null
@ -45,11 +51,17 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
private val turnsToTech = civInfo.gameInfo.ruleSet.technologies.values.associateBy({ it.name }, { civTech.turnsToTech(it.name) }) private val turnsToTech = civInfo.gameInfo.ruleSet.technologies.values.associateBy({ it.name }, { civTech.turnsToTech(it.name) })
init { init {
setDefaultCloseAction() setDefaultCloseAction()
onBackButtonClicked { UncivGame.Current.setWorldScreen() } onBackButtonClicked { UncivGame.Current.setWorldScreen() }
scrollPane.setOverscroll(false, false) scrollPane.setOverscroll(false, false)
descriptionLabel.onClick {
if (selectedTech != null)
game.setScreen(CivilopediaScreen(civInfo.gameInfo.ruleSet, CivilopediaCategories.Technology, selectedTech!!.name))
}
tempTechsToResearch = ArrayList(civTech.techsToResearch) tempTechsToResearch = ArrayList(civTech.techsToResearch)
createTechTable() createTechTable()