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
2 changed files with 40 additions and 4 deletions

View File

@ -92,6 +92,10 @@ class Technology: RulesetObject() {
if (tileImprovements.isNotEmpty())
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() }
}
@ -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"
@ -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
}
}

View File

@ -12,12 +12,18 @@ import com.unciv.logic.civilization.TechManager
import com.unciv.models.UncivSound
import com.unciv.models.ruleset.tech.Technology
import com.unciv.models.translations.tr
import com.unciv.ui.civilopedia.CivilopediaCategories
import com.unciv.ui.civilopedia.CivilopediaScreen
import com.unciv.ui.utils.*
import java.util.*
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 selectedTech: Technology? = null
@ -50,6 +56,12 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
setDefaultCloseAction()
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
scrollPane.setOverscroll(false, false)
descriptionLabel.onClick {
if (selectedTech != null)
game.setScreen(CivilopediaScreen(civInfo.gameInfo.ruleSet, CivilopediaCategories.Technology, selectedTech!!.name))
}
tempTechsToResearch = ArrayList(civTech.techsToResearch)
createTechTable()