mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 20:59:18 +07:00
Added secondary colors for civs - applies to units, cities, minimap, and more!
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package com.unciv.models.gamebasics.tile
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
class Terrain : NamedStats(), ICivilopedia {
|
||||
override val description: String
|
||||
@ -47,8 +49,8 @@ class Terrain : NamedStats(), ICivilopedia {
|
||||
* RGB color of base terrain
|
||||
*/
|
||||
var RGB: List<Int>? = null
|
||||
|
||||
var movementCost = 1
|
||||
|
||||
var defenceBonus:Float = 0f
|
||||
|
||||
fun getColor(): Color = colorFromRGB(RGB!![0], RGB!![1], RGB!![2])
|
||||
}
|
@ -49,8 +49,8 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
val sb = StringBuilder()
|
||||
if(baseDescription!=null) sb.appendln(baseDescription!!.tr())
|
||||
if(!forPickerScreen) {
|
||||
if (unbuildable) sb.appendln("Unbuildable")
|
||||
if(uniqueTo!=null) sb.appendln("Unique to $uniqueTo, replaces $replaces")
|
||||
if (unbuildable) sb.appendln("Unbuildable".tr())
|
||||
else sb.appendln("Cost: $cost")
|
||||
if(requiredResource!=null) sb.appendln("Required resource: {$requiredResource}".tr())
|
||||
if(requiredTech!=null) sb.appendln("Required tech: {$requiredTech}".tr())
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
@ -31,8 +30,8 @@ class NewGameScreen: PickerScreen(){
|
||||
init {
|
||||
pad(10f)
|
||||
background=ImageGetter.getBackground(nation.getColor().apply { a=0.5f })
|
||||
add(Label(nation.name, skin).apply { setFontColor(Color.WHITE)}).row()
|
||||
add(Label(getUniqueLabel(nation), skin).apply { setWrap(true);setFontColor(Color.WHITE)}).width(width)
|
||||
add(Label(nation.name, skin).apply { setFontColor(nation.getSecondaryColor())}).row()
|
||||
add(Label(getUniqueLabel(nation), skin).apply { setWrap(true);setFontColor(nation.getSecondaryColor())}).width(width)
|
||||
addClickListener { newGameParameters.nation=nation.name; onClick() }
|
||||
touchable=Touchable.enabled
|
||||
update()
|
||||
|
@ -15,7 +15,6 @@ import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.cityscreen.YieldGroup
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.center
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
protected val hexagon = ImageGetter.getImage("TerrainIcons/Hexagon.png")
|
||||
@ -250,8 +249,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
}
|
||||
|
||||
private fun updateTileColor(isViewable: Boolean) {
|
||||
val RGB = tileInfo.getBaseTerrain().RGB!!
|
||||
hexagon.color = colorFromRGB(RGB[0], RGB[1], RGB[2])
|
||||
hexagon.color = tileInfo.getBaseTerrain().getColor()
|
||||
if (!isViewable) hexagon.color = hexagon.color.lerp(Color.BLACK, 0.6f)
|
||||
}
|
||||
|
||||
@ -322,25 +320,25 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
}
|
||||
|
||||
if (unit != null && isViewable) { // Tile is visible
|
||||
newImage = getUnitImage(unit, unit.civInfo.getNation().getColor(), 25f)
|
||||
newImage = getUnitImage(unit, 25f)
|
||||
addActor(newImage)
|
||||
newImage.center(this)
|
||||
newImage.y += yFromCenter
|
||||
|
||||
if (!unit.isIdle()) newImage.color = Color(1f, 1f, 1f, 0.5f)
|
||||
if (!unit.isIdle()) newImage.color.a = 0.5f
|
||||
}
|
||||
return newImage
|
||||
}
|
||||
|
||||
|
||||
private fun getUnitImage(unit: MapUnit, color: Color, size: Float): Group {
|
||||
val unitBaseImage = ImageGetter.getUnitIcon(unit.name)
|
||||
private fun getUnitImage(unit: MapUnit, size: Float): Group {
|
||||
val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.getNation().getSecondaryColor())
|
||||
.apply { setSize(20f, 20f) }
|
||||
|
||||
val background = if (unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")
|
||||
else ImageGetter.getImage("OtherIcons/Circle.png")
|
||||
background.apply {
|
||||
this.color = color
|
||||
this.color = unit.civInfo.getNation().getColor()
|
||||
setSize(size, size)
|
||||
}
|
||||
val group = Group().apply {
|
||||
|
@ -77,6 +77,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
if (cityButton == null) {
|
||||
cityButton = Table()
|
||||
cityButton!!.background = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
|
||||
.tint(city.civInfo.getNation().getColor())
|
||||
cityButton!!.isTransform = true // If this is not set then the city button won't scale!
|
||||
|
||||
addActor(cityButton)
|
||||
@ -85,7 +86,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
|
||||
val cityButtonText = city.name + " (" + city.population.population + ")"
|
||||
val label = Label(cityButtonText, CameraStageBaseScreen.skin)
|
||||
label.setFontColor(city.civInfo.getNation().getColor())
|
||||
label.setFontColor(city.civInfo.getNation().getSecondaryColor())
|
||||
if (city.civInfo.isPlayerCivilization())
|
||||
label.addClickListener {
|
||||
UnCivGame.Current.screen = CityScreen(city)
|
||||
@ -130,17 +131,27 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
private fun getConstructionGroup(cityConstructions: CityConstructions):Group{
|
||||
val group= Group()
|
||||
val groupHeight = 25f
|
||||
group.setSize(35f,groupHeight)
|
||||
group.setSize(40f,groupHeight)
|
||||
|
||||
val circle = ImageGetter.getImage("OtherIcons/Circle")
|
||||
circle.setSize(25f,25f)
|
||||
val image = ImageGetter.getConstructionImage(cityConstructions.currentConstruction)
|
||||
image.setSize(20f,20f)
|
||||
image.centerY(group)
|
||||
image.x = group.width-image.width
|
||||
|
||||
// center the circle on thee production image
|
||||
circle.x = image.x + (image.width-circle.width)/2
|
||||
circle.y = image.y + (image.height-circle.height)/2
|
||||
|
||||
group.addActor(circle)
|
||||
group.addActor(image)
|
||||
|
||||
val secondaryColor = cityConstructions.cityInfo.civInfo.getNation().getSecondaryColor()
|
||||
if(cityConstructions.getCurrentConstruction() !is SpecialConstruction) {
|
||||
val turnsToConstruction = cityConstructions.turnsToConstruction(cityConstructions.currentConstruction)
|
||||
val label = Label(turnsToConstruction.toString(),CameraStageBaseScreen.skin)
|
||||
label.color = Color.BROWN
|
||||
label.setFontColor(secondaryColor)
|
||||
label.setFont(10)
|
||||
label.pack()
|
||||
group.addActor(label)
|
||||
|
@ -52,8 +52,8 @@ object ImageGetter {
|
||||
.apply { setSize(20f,20f)}
|
||||
}
|
||||
|
||||
fun getUnitIcon(unitName:String):Image{
|
||||
return getImage("UnitIcons/$unitName")
|
||||
fun getUnitIcon(unitName:String,color:Color= Color.BLACK):Image{
|
||||
return getImage("UnitIcons/$unitName").apply { this.color=color }
|
||||
}
|
||||
|
||||
fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{
|
||||
|
@ -12,7 +12,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.addClickListener
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
||||
val allTiles = Group()
|
||||
@ -73,12 +72,11 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
||||
fun update(cloneCivilization: CivilizationInfo) {
|
||||
val exploredTiles = cloneCivilization.exploredTiles
|
||||
for(tileInfo in tileMapHolder.tileMap.values) {
|
||||
val RGB = tileInfo.getBaseTerrain().RGB!!
|
||||
val hex = tileImages[tileInfo]!!
|
||||
if (!(exploredTiles.contains(tileInfo.position) || UnCivGame.Current.viewEntireMapForDebug)) hex.color = Color.BLACK
|
||||
else if (tileInfo.isCityCenter()) hex.color = Color.WHITE
|
||||
else if (tileInfo.isCityCenter()) hex.color = tileInfo.getOwner()!!.getNation().getSecondaryColor()
|
||||
else if (tileInfo.getCity() != null) hex.color = tileInfo.getOwner()!!.getNation().getColor()
|
||||
else hex.color = colorFromRGB(RGB[0], RGB[1], RGB[2]).lerp(Color.GRAY, 0.5f) // Todo add to baseterrain as function
|
||||
else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f) // Todo add to baseterrain as function
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user