mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
Added color to civilopedia buttons per #3503
This commit is contained in:
@ -16,18 +16,23 @@ import kotlin.math.abs
|
||||
open class TileInfo {
|
||||
@Transient
|
||||
lateinit var tileMap: TileMap
|
||||
|
||||
@Transient
|
||||
lateinit var ruleset: Ruleset // a tile can be a tile with a ruleset, even without a map.
|
||||
|
||||
@Transient
|
||||
var owningCity: CityInfo? = null
|
||||
|
||||
@Transient
|
||||
private lateinit var baseTerrainObject: Terrain
|
||||
|
||||
// These are for performance - checked with every tile movement and "canEnter" check, which makes them performance-critical
|
||||
@Transient
|
||||
var isLand = false
|
||||
|
||||
@Transient
|
||||
var isWater = false
|
||||
|
||||
@Transient
|
||||
var isOcean = false
|
||||
|
||||
@ -174,9 +179,7 @@ open class TileInfo {
|
||||
return civInfo.cities.firstOrNull { it.isWorked(this) }
|
||||
}
|
||||
|
||||
fun isWorked(): Boolean {
|
||||
return getWorkingCity() != null
|
||||
}
|
||||
fun isWorked(): Boolean = getWorkingCity() != null
|
||||
|
||||
fun isLocked(): Boolean {
|
||||
val workingCity = getWorkingCity()
|
||||
@ -490,7 +493,7 @@ open class TileInfo {
|
||||
/** If the unit isn't in the ruleset we can't even know what type of unit this is! So check each place
|
||||
* This works with no transients so can be called from gameInfo.setTransients with no fear
|
||||
*/
|
||||
fun removeUnit(mapUnit: MapUnit){
|
||||
fun removeUnit(mapUnit: MapUnit) {
|
||||
when {
|
||||
airUnits.contains(mapUnit) -> airUnits.remove(mapUnit)
|
||||
civilianUnit == mapUnit -> civilianUnit = null
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
@ -27,13 +28,17 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
|
||||
fun select(category: String) {
|
||||
entrySelectTable.clear()
|
||||
|
||||
for (button in categoryToButtons.values) button.color = Color.WHITE
|
||||
categoryToButtons[category]!!.color = Color.BLUE
|
||||
|
||||
var entries = categoryToEntries[category]!!
|
||||
if(category!="Difficulty levels") // this is the only case where we need them in order
|
||||
entries = entries.sortedBy { it.name.tr() } // Alphabetical order of localized names
|
||||
for (entry in entries){
|
||||
if (category != "Difficulty levels") // this is the only case where we need them in order
|
||||
entries = entries.sortedBy { it.name.tr() } // Alphabetical order of localized names
|
||||
for (entry in entries) {
|
||||
val entryButton = Button(skin)
|
||||
if(entry.image!=null)
|
||||
if (category=="Terrains")
|
||||
if (entry.image != null)
|
||||
if (category == "Terrains")
|
||||
entryButton.add(entry.image).padRight(24f)
|
||||
else
|
||||
entryButton.add(entry.image).size(50f).padRight(10f)
|
||||
@ -49,39 +54,57 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
|
||||
categoryToEntries["Buildings"] = ruleset.buildings.values
|
||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques && !(it.isWonder||it.isNationalWonder) }
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f)) }
|
||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques && !(it.isWonder || it.isNationalWonder) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(false, null, ruleset),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f))
|
||||
}
|
||||
categoryToEntries["Wonders"] = ruleset.buildings.values
|
||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques && (it.isWonder||it.isNationalWonder) }
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f)) }
|
||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques && (it.isWonder || it.isNationalWonder) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(false, null, ruleset),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f))
|
||||
}
|
||||
categoryToEntries["Resources"] = ruleset.tileResources.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||
ImageGetter.getResourceImage(it.name,50f)) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(ruleset),
|
||||
ImageGetter.getResourceImage(it.name, 50f))
|
||||
}
|
||||
categoryToEntries["Terrains"] = ruleset.terrains.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||
terrainImage(it, ruleset) ) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(ruleset),
|
||||
terrainImage(it, ruleset))
|
||||
}
|
||||
categoryToEntries["Tile Improvements"] = ruleset.tileImprovements.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset,false),
|
||||
ImageGetter.getImprovementIcon(it.name,50f)) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(ruleset, false),
|
||||
ImageGetter.getImprovementIcon(it.name, 50f))
|
||||
}
|
||||
categoryToEntries["Units"] = ruleset.units.values
|
||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques }
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f)) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(false),
|
||||
ImageGetter.getConstructionImage(it.name).surroundWithCircle(50f))
|
||||
}
|
||||
categoryToEntries["Nations"] = ruleset.nations.values
|
||||
.filter { it.isMajorCiv() }
|
||||
.map { CivilopediaEntry(it.name,it.getUniqueString(ruleset,false),
|
||||
ImageGetter.getNationIndicator(it,50f)) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getUniqueString(ruleset, false),
|
||||
ImageGetter.getNationIndicator(it, 50f))
|
||||
}
|
||||
categoryToEntries["Technologies"] = ruleset.technologies.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||
ImageGetter.getTechIconGroup(it.name,50f)) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(ruleset),
|
||||
ImageGetter.getTechIconGroup(it.name, 50f))
|
||||
}
|
||||
categoryToEntries["Promotions"] = ruleset.unitPromotions.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset.unitPromotions.values, true, ruleset),
|
||||
Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) }
|
||||
.map {
|
||||
CivilopediaEntry(it.name, it.getDescription(ruleset.unitPromotions.values, true, ruleset),
|
||||
Table().apply { add(ImageGetter.getPromotionIcon(it.name)) })
|
||||
}
|
||||
|
||||
categoryToEntries["Tutorials"] = tutorialController.getCivilopediaTutorials()
|
||||
.map { CivilopediaEntry(it.key.replace("_"," "), it.value.joinToString("\n\n") { line -> line.tr() }) }
|
||||
.map { CivilopediaEntry(it.key.replace("_", " "), it.value.joinToString("\n\n") { line -> line.tr() }) }
|
||||
|
||||
categoryToEntries["Difficulty levels"] = ruleset.difficulties.values
|
||||
.map { CivilopediaEntry(it.name, it.getDescription()) }
|
||||
@ -139,10 +162,10 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
select("Tutorials")
|
||||
}
|
||||
|
||||
private fun terrainImage (terrain: Terrain, ruleset: Ruleset): Actor? {
|
||||
private fun terrainImage(terrain: Terrain, ruleset: Ruleset): Actor? {
|
||||
val tileInfo = TileInfo()
|
||||
tileInfo.ruleset = ruleset
|
||||
when(terrain.type) {
|
||||
when (terrain.type) {
|
||||
TerrainType.NaturalWonder -> {
|
||||
tileInfo.naturalWonder = terrain.name
|
||||
tileInfo.baseTerrain = terrain.turnsInto ?: Constants.grassland
|
||||
@ -161,5 +184,4 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
group.update()
|
||||
return group
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user