Highlight non-available wonders in tech picker (#9173)

* Show wonders in tech tree with a blue color and also show which wonders have already been built for technologies not yet researched with a red circle around them.

* Only show red circle.
This commit is contained in:
WhoIsJohannes
2023-04-13 10:54:35 +02:00
committed by GitHub
parent 0500f73770
commit e72591e470
2 changed files with 25 additions and 1 deletions

View File

@ -171,6 +171,12 @@ class PortraitBuilding(name: String, size: Float) : Portrait(Type.Building, name
}
}
class PortraitUnavailableWonderForTechTree(name: String, size: Float) : Portrait(Type.Building, name, size) {
override fun getDefaultOuterBackgroundTint(): Color {
return Color.RED
}
}
class PortraitUnique(name: String, size: Float) : Portrait(Type.Unique, name, size) {
override fun getDefaultImageTint(): Color {
return Color.BLACK

View File

@ -15,6 +15,7 @@ import com.unciv.models.translations.tr
import com.unciv.ui.components.Fonts
import com.unciv.ui.components.extensions.center
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.images.PortraitUnavailableWonderForTechTree
import com.unciv.ui.screens.civilopediascreen.FormattedLine
import com.unciv.ui.screens.civilopediascreen.ICivilopediaText
import com.unciv.ui.screens.pickerscreens.TechButton
@ -91,7 +92,24 @@ object TechnologyDescriptions {
}
for (building in getEnabledBuildings(techName, ruleset, viewingCiv)) {
yield(ImageGetter.getConstructionPortrait(building.name, techIconSize))
// We don't need to show the unavailable marker for techs that are already researched
// since this is mostly a feature to choose which technologies to research.
if (building.isWonder && !viewingCiv.tech.isResearched(techName)) {
val isAlreadyBuilt = viewingCiv.gameInfo.getCities()
// This is theoretically not necessary since we already checked the viewingCiv
// doesn't have the tech, so it can't have this built anyways. It should be a
// little more performant though to add this filter.
.filter{ it.civ != viewingCiv }
.any { it.cityConstructions.builtBuildings.contains(building.name) }
val wonderConstructionPortrait =
if (isAlreadyBuilt)
PortraitUnavailableWonderForTechTree(building.name, techIconSize)
else
ImageGetter.getConstructionPortrait(building.name, techIconSize)
yield(wonderConstructionPortrait)
} else {
yield(ImageGetter.getConstructionPortrait(building.name, techIconSize))
}
}
yieldAll(