Code organization - separated TechButton and IconCircleGroup to separate files &c

Tech with special abilities now displayed with a star icon
This commit is contained in:
Yair Morgenstern 2018-11-04 18:42:55 +02:00
parent 937687a0f4
commit 02b0f6e9fe
14 changed files with 475 additions and 447 deletions

View File

@ -17,7 +17,7 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
* [Bow And Arrow](https://thenounproject.com/search/?q=Bow%20and%20Arrow&i=338261) By Viktor Ostrovsky for Archer * [Bow And Arrow](https://thenounproject.com/search/?q=Bow%20and%20Arrow&i=338261) By Viktor Ostrovsky for Archer
* [Bow](https://thenounproject.com/search/?q=bow&i=101736) By Arthur Shlain for Bowman * [Bow](https://thenounproject.com/search/?q=bow&i=101736) By Arthur Shlain for Bowman
* [Fishing Vessel](https://thenounproject.com/term/fishing-vessel/23815/) By Luis Prado for Work Boats * [Fishing Vessel](https://thenounproject.com/term/fishing-vessel/23815/) By Luis Prado for Work Boats
* [Greek Trireme](https://thenounproject.com/search/?q=ancient%20boat&i=1626303) By Zachary McCune for Triremehos * [Greek Trireme](https://thenounproject.com/search/?q=ancient%20boat&i=1626303) By Zachary McCune for Trireme
* [Chariot](https://thenounproject.com/search/?q=Chariot&i=1189930) By Andrew Doane for Chariot Archer * [Chariot](https://thenounproject.com/search/?q=Chariot&i=1189930) By Andrew Doane for Chariot Archer
* [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger for Spearman * [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger for Spearman

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 KiB

After

Width:  |  Height:  |  Size: 761 KiB

View File

@ -2,17 +2,16 @@
// Ancient Era // Ancient Era
{ {
name:"Palace", name:"Palace",
baseDescription: "Indicates that this city is the capital",
isWonder:true, isWonder:true,
production:3, production:3,
science:3, science:3,
gold:3, gold:3,
culture:1, culture:1,
cost:1 cost:1,
uniques:["Indicates the capital city"]
}, },
{ {
name:"Monument", name:"Monument",
baseDescription: "Produces culture, enabling border growth",
culture:2, culture:2,
cost:40, cost:40,
hurryCostModifier:40, hurryCostModifier:40,
@ -45,7 +44,6 @@
}, },
{ {
name:"The Great Library", name:"The Great Library",
baseDescription: "Provides a free technology, and a library in the city it is built in",
science:3, science:3,
culture:1, culture:1,
greatPersonPoints:{science:1}, greatPersonPoints:{science:1},
@ -86,7 +84,6 @@
}, },
{ {
name:"The Pyramids", name:"The Pyramids",
baseDescription: "Worker construction increased 25%, provides 2 free workers",
culture:1, culture:1,
greatPersonPoints:{production:1}, greatPersonPoints:{production:1},
isWonder:true, isWonder:true,
@ -173,7 +170,6 @@
}, },
{ {
name:"The Oracle", name:"The Oracle",
baseDescription: "Provides a free social policy",
culture:3, culture:3,
greatPersonPoints:{science:1}, greatPersonPoints:{science:1},
isWonder:true, isWonder:true,
@ -349,11 +345,11 @@
{ {
name:"Observatory", name:"Observatory",
baseDescription: "City must be bordering a mountain",
maintenance:2, maintenance:2,
hurryCostModifier:25, hurryCostModifier:25,
percentStatBonus:{science:50}, percentStatBonus:{science:50},
requiredBuilding:"Library", requiredBuilding:"Library",
uniques:[] //todo: "City must be bordering a mountain",
requiredTech:"Astronomy" requiredTech:"Astronomy"
}, },
{ {
@ -415,7 +411,6 @@
}, },
{ {
name:"The Louvre", name:"The Louvre",
baseDescription: "A Free Great Artist appears near the city",
culture:1, culture:1,
happiness:4, happiness:4,
isWonder:true, isWonder:true,
@ -424,7 +419,6 @@
}, },
{ {
name:"Taj Mahal", name:"Taj Mahal",
baseDescription: "Empire enters a golden age",
culture:1, culture:1,
happiness:4, happiness:4,
isWonder:true, isWonder:true,
@ -510,7 +504,6 @@
}, },
{ {
name:"Eiffel Tower", name:"Eiffel Tower",
baseDescription: "Provides 1 happiness per social policy",
culture:1, culture:1,
happiness:5 happiness:5
isWonder:true, isWonder:true,
@ -562,7 +555,6 @@
}, },
{ {
name:"Solar Plant", name:"Solar Plant",
baseDescription: "Can only be built in cities next to deserts; cannot be built in a city with a Nuclear Plant",
production:5, production:5,
percentStatBonus:{production:15}, percentStatBonus:{production:15},
requiredBuilding:"Factory", requiredBuilding:"Factory",

View File

@ -2189,24 +2189,6 @@
Spanish:"Tecnología del futuro" Spanish:"Tecnología del futuro"
} }
//Why do we have duplicates? Anyway i have translated it
"Enables conversion of city production to gold":{
Russian:"Разрешает конверсию производства в золото"
Spanish:"Habilita la conversión de producción a oro"
}
"Enables conversion of city production to science":{
Russian:"Разрешает конверсию производства в науку"
Spanish:"Habilita la conversión de producción a ciencia"
}
"Improves movement speed on roads":{
Russian:"Ускоряет скорость передвижения по дорогам"
Spanish:"Mejora la velocidad de movimiento en carreteras"
}
"+10% science and production in all cities":{
Russian:"+10% науки и производства во всех городах"
Spanish:"+10% de ciencia y producción en todas las ciudades"
}
"Who knows what the future holds?":{ "Who knows what the future holds?":{
Italian:"Chi sa cosa riserva il futuro?" Italian:"Chi sa cosa riserva il futuro?"
@ -2217,6 +2199,15 @@
Spanish:"¿Quién sabe qué nos depara el futuro?" Spanish:"¿Quién sabe qué nos depara el futuro?"
} }
"Improves movement speed on roads":{
Russian:"Ускоряет скорость передвижения по дорогам"
Spanish:"Mejora la velocidad de movimiento en carreteras"
}
"+10% science and production in all cities":{
Russian:"+10% науки и производства во всех городах"
Spanish:"+10% de ciencia y producción en todas las ciudades"
}
"Improves movement speed on roads":{ "Improves movement speed on roads":{
Italian:"Migliora la velocità di movimento sulle strade" Italian:"Migliora la velocità di movimento sulle strade"
Russian:"Улучшает скорость передвижения по дорогам" Russian:"Улучшает скорость передвижения по дорогам"
@ -2238,6 +2229,7 @@
Romanian:"Permite conversia producției în oraș la aur" Romanian:"Permite conversia producției în oraș la aur"
Spanish:"Habilita la conversión de producción a oro" Spanish:"Habilita la conversión de producción a oro"
} }
"Increases embarked movement +1":{}
// Tech Eras // Tech Eras
// In case of foreign languages it becomes gender sensitive words // In case of foreign languages it becomes gender sensitive words
@ -3574,6 +3566,8 @@
// And finally, units! // And finally, units!
// Ancient Era Units
"Worker":{ "Worker":{
Italian:"Operaio" Italian:"Operaio"
Russian:"Рабочий" Russian:"Рабочий"
@ -3581,6 +3575,7 @@
Romanian:"Lucrător" Romanian:"Lucrător"
Spanish:"Trabajador" Spanish:"Trabajador"
} }
// Settler already translated in difficulties
"Scout":{ "Scout":{
Italian:"Esploratore" Italian:"Esploratore"
Russian:"Разведчик" Russian:"Разведчик"
@ -3608,6 +3603,8 @@
//In official Russian localization it's accurate archer :) //In official Russian localization it's accurate archer :)
Spanish:"Arquero experto" Spanish:"Arquero experto"
} }
"Work Boats":{}
"Trireme":{}
"Chariot Archer":{ "Chariot Archer":{
Italian:"Arciere in carriola" Italian:"Arciere in carriola"
Russian:"Лучник на колеснице" Russian:"Лучник на колеснице"
@ -3622,6 +3619,8 @@
Romanian:"Lancer" Romanian:"Lancer"
Spanish:"Lancero" Spanish:"Lancero"
} }
// Classical Era Units
"Catapult":{ "Catapult":{
Italian:"Catapulta" Italian:"Catapulta"
Russian:"Катапульта" Russian:"Катапульта"
@ -3629,6 +3628,7 @@
Romanian:"Catapulta" Romanian:"Catapulta"
Spanish:"Catapulta" Spanish:"Catapulta"
} }
"Ballista":{}
"Swordsman":{ "Swordsman":{
Italian:"Spadaccino" Italian:"Spadaccino"
Russian:"Мечник" Russian:"Мечник"
@ -3650,6 +3650,9 @@
Romanian:"Compania cavalerilor" Romanian:"Compania cavalerilor"
Spanish:"Caballería de compañia" Spanish:"Caballería de compañia"
} }
// Medieval units
"Galleass":{}
"Crossbowman":{ "Crossbowman":{
Italian:"Balestriere" Italian:"Balestriere"
Russian:"Арбалетчик" Russian:"Арбалетчик"
@ -3685,6 +3688,9 @@
Romanian:"Cavaler" Romanian:"Cavaler"
Spanish:"Caballero" Spanish:"Caballero"
} }
// Renaissance units
"Caravel":{}
"Cannon":{ "Cannon":{
Italian:"Cannone" Italian:"Cannone"
Russian:"Пушка" Russian:"Пушка"
@ -3697,6 +3703,7 @@
French:"Mousquetaire" French:"Mousquetaire"
Spanish:"Mosquetero" Spanish:"Mosquetero"
} }
"Musketeer":{}
"Lancer":{ "Lancer":{
Italian:"lanciere" Italian:"lanciere"
Russian:"Улан" Russian:"Улан"
@ -3704,6 +3711,8 @@
Romanian:"Lăncier" Romanian:"Lăncier"
Spanish:"Jinete lancero" Spanish:"Jinete lancero"
} }
// Industrial units
"Rifleman":{ "Rifleman":{
Italian:"Fuciliere" Italian:"Fuciliere"
Russian:"Стрелок" Russian:"Стрелок"
@ -3725,6 +3734,8 @@
Romanian:"Artilerie" Romanian:"Artilerie"
Spanish:"Artillería" Spanish:"Artillería"
} }
// Great units
"Great Artist":{ "Great Artist":{
Italian:"Grande artista" Italian:"Grande artista"
Russian:"Великий художник" Russian:"Великий художник"
@ -3754,6 +3765,7 @@
Spanish:"Gran Ingeniero" Spanish:"Gran Ingeniero"
} }
// Social policies
"Requires":{ "Requires":{
Russian:"Требует" Russian:"Требует"
Spanish:"Requiere" Spanish:"Requiere"

View File

@ -8,7 +8,6 @@ import com.unciv.models.stats.Stats
import com.unciv.ui.utils.tr import com.unciv.ui.utils.tr
class Building : NamedStats(), IConstruction{ class Building : NamedStats(), IConstruction{
private var baseDescription: String? = null
override val description: String override val description: String
get() = getDescription(false, hashSetOf()) get() = getDescription(false, hashSetOf())

View File

@ -12,7 +12,6 @@ class Technology : ICivilopedia {
val SB=StringBuilder() val SB=StringBuilder()
if(baseDescription!=null) SB.appendln(baseDescription!!.tr()) if(baseDescription!=null) SB.appendln(baseDescription!!.tr())
val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString() } val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString() }
for (improvement in improvedImprovements) { for (improvement in improvedImprovements) {
val impimpString = improvement.value.joinToString { it.name.tr() } +" {provide" + (if(improvement.value.size==1) "s" else "") +"} "+improvement.key val impimpString = improvement.value.joinToString { it.name.tr() } +" {provide" + (if(improvement.value.size==1) "s" else "") +"} "+improvement.key

View File

@ -0,0 +1,63 @@
package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.logic.civilization.TechManager
import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.setFontColor
import com.unciv.ui.utils.surroundWithCircle
class TechButton(techName:String, val techManager: TechManager) : Table(CameraStageBaseScreen.skin) {
val text= Label("", skin).setFontColor(Color.WHITE).apply { setAlignment(Align.center) }
init {
touchable = Touchable.enabled
defaults().pad(10f)
background = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
if(ImageGetter.techIconExists(techName))
add(ImageGetter.getTechIconGroup(techName)) // this is 60*60
val rightSide = Table()
val techCost = techManager.costOfTech(techName)
val remainingTech = techManager.remainingScienceToTech(techName)
if(techCost!=remainingTech){
val percentComplete = (techCost-remainingTech)/techCost.toFloat()
add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE))
}
rightSide.add(text).row()
// here we add little images of what the tech gives you
val techEnabledIcons = Table()
techEnabledIcons.defaults().pad(5f)
for(unit in GameBasics.Units.values.filter { it.requiredTech==techName
&& (it.uniqueTo==null || it.uniqueTo==techManager.civInfo.civName) })
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
for(building in GameBasics.Buildings.values.filter { it.requiredTech==techName
&& (it.uniqueTo==null || it.uniqueTo==techManager.civInfo.civName)})
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
for(improvement in GameBasics.TileImprovements.values.filter { it.techRequired==techName || it.improvingTech==techName }) {
if(improvement.name.startsWith("Remove"))
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(30f)
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
}
for(resource in GameBasics.TileResources.values.filter { it.revealedBy==techName })
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
val tech = GameBasics.Technologies[techName]!!
if(tech.baseDescription!=null)
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star").apply { color= Color.BLACK }.surroundWithCircle(30f))
rightSide.add(techEnabledIcons)
add(rightSide)
pack()
}
}

View File

@ -1,10 +1,7 @@
package com.unciv.ui.pickerscreens package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.UnCivGame import com.unciv.UnCivGame
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.TechManager import com.unciv.logic.civilization.TechManager
@ -13,6 +10,7 @@ import com.unciv.models.gamebasics.tech.Technology
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
import java.util.* import java.util.*
class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen() { class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen() {
private var techNameToButton = HashMap<String, TechButton>() private var techNameToButton = HashMap<String, TechButton>()
@ -37,52 +35,6 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
isFreeTechPick = freeTechPick isFreeTechPick = freeTechPick
} }
class TechButton(techName:String, val techManager:TechManager) : Table(skin) {
val text=Label("",skin).setFontColor(Color.WHITE).apply { setAlignment(Align.center) }
init {
touchable = Touchable.enabled
defaults().pad(10f)
background = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
if(ImageGetter.techIconExists(techName))
add(ImageGetter.getTechIconGroup(techName)) // this is 60*60
val rightSide = Table()
val techCost = techManager.costOfTech(techName)
val remainingTech = techManager.remainingScienceToTech(techName)
if(techCost!=remainingTech){
val percentComplete = (techCost-remainingTech)/techCost.toFloat()
add(ImageGetter.getProgressBarVertical(2f,50f,percentComplete, Color.BLUE, Color.WHITE))
}
rightSide.add(text).row()
// here we add little images of what the tech gives you
val techEnabledIcons = Table()
techEnabledIcons.defaults().pad(5f)
for(unit in GameBasics.Units.values.filter { it.requiredTech==techName
&& (it.uniqueTo==null || it.uniqueTo==techManager.civInfo.civName) })
techEnabledIcons.add(ImageGetter.IconCircleGroup(30f,ImageGetter.getConstructionImage(unit.name)))
for(building in GameBasics.Buildings.values.filter { it.requiredTech==techName
&& (it.uniqueTo==null || it.uniqueTo==techManager.civInfo.civName)})
techEnabledIcons.add(ImageGetter.IconCircleGroup(30f,ImageGetter.getConstructionImage(building.name)))
for(improvement in GameBasics.TileImprovements.values.filter { it.techRequired==techName || it.improvingTech==techName }) {
if(improvement.name.startsWith("Remove"))
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Stop")).size(30f)
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
}
for(resource in GameBasics.TileResources.values.filter { it.revealedBy==techName })
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name,30f))
rightSide.add(techEnabledIcons)
add(rightSide)
pack()
}
}
init { init {
onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() } onBackButtonClicked { UnCivGame.Current.setWorldScreen(); dispose() }

View File

@ -228,7 +228,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
} }
if (roadStatus == RoadStatus.None) continue // no road image if (roadStatus == RoadStatus.None) continue // no road image
val image = if (roadStatus == RoadStatus.Road) ImageGetter.getImage(ImageGetter.WhiteDot).apply { color = Color.BROWN } val image = if (roadStatus == RoadStatus.Road) ImageGetter.getWhiteDot().apply { color = Color.BROWN }
else ImageGetter.getImage("OtherIcons/Railroad.png") else ImageGetter.getImage("OtherIcons/Railroad.png")
roadImage.image = image roadImage.image = image
@ -378,13 +378,13 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
protected fun getHealthBar(currentHealth: Float, maxHealth: Float, healthBarSize: Float): Table { protected fun getHealthBar(currentHealth: Float, maxHealth: Float, healthBarSize: Float): Table {
val healthPercent = currentHealth / maxHealth val healthPercent = currentHealth / maxHealth
val healthBar = Table() val healthBar = Table()
val healthPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot) val healthPartOfBar = ImageGetter.getWhiteDot()
healthPartOfBar.color = when { healthPartOfBar.color = when {
healthPercent > 2 / 3f -> Color.GREEN healthPercent > 2 / 3f -> Color.GREEN
healthPercent > 1 / 3f -> Color.ORANGE healthPercent > 1 / 3f -> Color.ORANGE
else -> Color.RED else -> Color.RED
} }
val emptyPartOfBar = ImageGetter.getImage(ImageGetter.WhiteDot).apply { color = Color.BLACK } val emptyPartOfBar = ImageGetter.getWhiteDot().apply { color = Color.BLACK }
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f) healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f) healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
healthBar.pack() healthBar.pack()

View File

@ -190,3 +190,6 @@ fun Actor.onClick(function: () -> Unit) {
} ) } )
} }
fun Image.surroundWithCircle(size:Float): IconCircleGroup {
return IconCircleGroup(size,this)
}

View File

@ -0,0 +1,15 @@
package com.unciv.ui.utils
import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.Image
class IconCircleGroup(size:Float, val image: Image): Group(){
val circle = ImageGetter.getImage("OtherIcons/Circle").apply { setSize(size, size) }
init {
setSize(size, size)
addActor(circle)
image.setSize(size * 0.75f, size * 0.75f)
image.center(this)
addActor(image)
}
}

View File

@ -14,7 +14,7 @@ import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceType import com.unciv.models.gamebasics.tile.ResourceType
object ImageGetter { object ImageGetter {
const val WhiteDot = "OtherIcons/whiteDot.png" const private val whiteDotLocation = "OtherIcons/whiteDot.png"
// When we used to load images directly from different files, without using a texture atlas, // When we used to load images directly from different files, without using a texture atlas,
// The draw() phase of the main screen would take a really long time because the BatchRenderer would // The draw() phase of the main screen would take a really long time because the BatchRenderer would
@ -22,9 +22,8 @@ object ImageGetter {
// So, we now use TexturePacker in the DesktopLauncher class to pack all the different images into single images, // So, we now use TexturePacker in the DesktopLauncher class to pack all the different images into single images,
// and the atlas is what tells us what was packed where. // and the atlas is what tells us what was packed where.
var atlas = TextureAtlas("game.atlas") var atlas = TextureAtlas("game.atlas")
fun getWhiteDot() = getImage(whiteDotLocation)
init{
}
fun getExternalImage(fileName:String): Image { fun getExternalImage(fileName:String): Image {
return Image(TextureRegion(Texture("ExtraImages/$fileName.png"))) return Image(TextureRegion(Texture("ExtraImages/$fileName.png")))
@ -49,7 +48,7 @@ object ImageGetter {
throw Exception("Could not find $fileName") throw Exception("Could not find $fileName")
return region return region
} catch (ex: Exception) { } catch (ex: Exception) {
return getTextureRegion(WhiteDot) return getTextureRegion(whiteDotLocation)
} }
} }
@ -66,16 +65,19 @@ object ImageGetter {
return getImage("UnitIcons/$unitName").apply { this.color=color } return getImage("UnitIcons/$unitName").apply { this.color=color }
} }
val foodCircleColor = Color.GREEN.cpy().lerp(Color.WHITE,0.5f)
val productionCircleColor = Color.BROWN.cpy().lerp(Color.WHITE,0.5f)
val goldCircleColor = Color.GOLD.cpy().lerp(Color.WHITE,0.5f)
fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{ fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{
val iconGroup = IconCircleGroup(size, getImage("ImprovementIcons/$improvementName")) val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
val improvement = GameBasics.TileImprovements[improvementName]!! val improvement = GameBasics.TileImprovements[improvementName]!!
when { when {
improvement.food>0 -> iconGroup.circle.color= Color.GREEN.cpy().lerp(Color.WHITE,0.5f) improvement.food>0 -> iconGroup.circle.color= foodCircleColor
improvement.production>0 -> iconGroup.circle.color= Color.BROWN.cpy().lerp(Color.WHITE,0.5f) improvement.production>0 -> iconGroup.circle.color= productionCircleColor
improvement.gold>0 -> iconGroup.circle.color= Color.GOLD.cpy().lerp(Color.WHITE,0.5f) improvement.gold>0 -> iconGroup.circle.color= goldCircleColor
improvement.science>0 -> iconGroup.circle.color= Color.GOLD.cpy().lerp(Color.BLUE,0.5f) improvement.science>0 -> iconGroup.circle.color= Color.BLUE.cpy().lerp(Color.WHITE,0.5f)
improvement.culture>0 -> iconGroup.circle.color= Color.GOLD.cpy().lerp(Color.PURPLE,0.5f) improvement.culture>0 -> iconGroup.circle.color= Color.PURPLE.cpy().lerp(Color.WHITE,0.5f)
} }
return iconGroup return iconGroup
@ -95,7 +97,7 @@ object ImageGetter {
fun getBlue() = Color(0x004085bf) fun getBlue() = Color(0x004085bf)
fun getBackground(color:Color): Drawable { fun getBackground(color:Color): Drawable {
return getDrawable(WhiteDot).tint(color) return getDrawable(whiteDotLocation).tint(color)
} }
fun refreshAltas() { fun refreshAltas() {
@ -103,11 +105,13 @@ object ImageGetter {
} }
fun getResourceImage(resourceName: String, size:Float): Actor { fun getResourceImage(resourceName: String, size:Float): Actor {
val iconGroup = IconCircleGroup(size,getImage("ResourceIcons/$resourceName")) val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
val resource = GameBasics.TileResources[resourceName]!! val resource = GameBasics.TileResources[resourceName]!!
if(resource.food>0) iconGroup.circle.color= Color.GREEN.cpy().lerp(Color.WHITE,0.5f) when {
else if(resource.production>0) iconGroup.circle.color= Color.BROWN.cpy().lerp(Color.WHITE,0.5f) resource.food>0 -> iconGroup.circle.color= foodCircleColor
else if(resource.gold>0) iconGroup.circle.color= Color.GOLD.cpy().lerp(Color.WHITE,0.5f) resource.production>0 -> iconGroup.circle.color= productionCircleColor
resource.gold>0 -> iconGroup.circle.color= goldCircleColor
}
if(resource.resourceType==ResourceType.Luxury){ if(resource.resourceType==ResourceType.Luxury){
val happiness = getStatIcon("Happiness") val happiness = getStatIcon("Happiness")
@ -125,27 +129,15 @@ object ImageGetter {
} }
fun getTechIconGroup(techName: String): Group { fun getTechIconGroup(techName: String): Group {
return IconCircleGroup(60f,getImage("TechIcons/$techName")) return getImage("TechIcons/$techName").surroundWithCircle(60f)
} }
fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table { fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table {
val advancementGroup = Table() val advancementGroup = Table()
val completionHeight = height * percentComplete val completionHeight = height * percentComplete
advancementGroup.add(ImageGetter.getImage(ImageGetter.WhiteDot).apply { color = backgroundColor }).width(width).height(height-completionHeight).row() advancementGroup.add(getImage(whiteDotLocation).apply { color = backgroundColor }).width(width).height(height-completionHeight).row()
advancementGroup.add(ImageGetter.getImage(ImageGetter.WhiteDot).apply { color= progressColor}).width(width).height(completionHeight) advancementGroup.add(getImage(whiteDotLocation).apply { color= progressColor}).width(width).height(completionHeight)
advancementGroup.pack() advancementGroup.pack()
return advancementGroup return advancementGroup
} }
class IconCircleGroup(size:Float, val image:Image):Group(){
val circle = getImage("OtherIcons/Circle").apply { setSize(size, size) }
init {
setSize(size, size)
addActor(circle)
image.setSize(size * 0.75f, size * 0.75f)
image.center(this)
addActor(image)
}
}
} }

View File

@ -14,6 +14,7 @@ import com.unciv.logic.civilization.DiplomaticStatus
import com.unciv.models.gamebasics.tile.ResourceType import com.unciv.models.gamebasics.tile.ResourceType
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.ui.pickerscreens.TechButton
import com.unciv.ui.pickerscreens.TechPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen
import com.unciv.ui.trade.DiplomacyScreen import com.unciv.ui.trade.DiplomacyScreen
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
@ -32,7 +33,7 @@ class WorldScreen : CameraStageBaseScreen() {
val unitActionsTable = UnitActionsTable(this) val unitActionsTable = UnitActionsTable(this)
private val techButton = Table() private val techButton = Table()
val diplomacyButtonWrapper = Table() private val diplomacyButtonWrapper = Table()
private val nextTurnButton = createNextTurnButton() private val nextTurnButton = createNextTurnButton()
private val notificationsScroll: NotificationsScroll private val notificationsScroll: NotificationsScroll
@ -178,7 +179,7 @@ class WorldScreen : CameraStageBaseScreen() {
} }
else { else {
val currentTech = civInfo.tech.currentTechnology()!! val currentTech = civInfo.tech.currentTechnology()!!
val innerButton = TechPickerScreen.TechButton(currentTech,civInfo.tech) val innerButton = TechButton(currentTech,civInfo.tech)
innerButton.color = colorFromRGB(7, 46, 43) innerButton.color = colorFromRGB(7, 46, 43)
techButton.add(innerButton) techButton.add(innerButton)
val turnsToTech = civInfo.tech.turnsToTech(currentTech) val turnsToTech = civInfo.tech.turnsToTech(currentTech)
@ -254,7 +255,7 @@ class WorldScreen : CameraStageBaseScreen() {
} }
} }
var shouldUpdate=false private var shouldUpdate=false
override fun render(delta: Float) { override fun render(delta: Float) {
if(shouldUpdate){ // This is so that updates happen in the MAIN THREAD, where there is a GL Context, if(shouldUpdate){ // This is so that updates happen in the MAIN THREAD, where there is a GL Context,
// otherwise images will not load properly! // otherwise images will not load properly!
@ -271,7 +272,7 @@ class WorldScreen : CameraStageBaseScreen() {
val resources = civInfo.getCivResources() val resources = civInfo.getCivResources()
if(resources.keys.any { it.resourceType==ResourceType.Luxury }) displayTutorials("LuxuryResource") if(resources.keys.any { it.resourceType==ResourceType.Luxury }) displayTutorials("LuxuryResource")
if(resources.keys.any { it.resourceType==ResourceType.Strategic}) displayTutorials("StrategicResource") if(resources.keys.any { it.resourceType==ResourceType.Strategic}) displayTutorials("StrategicResource")
if(civInfo.exploredTiles.map { gameInfo.tileMap[it] }.any { it.isCityCenter() && it.getOwner()!=civInfo }) if(civInfo.exploredTiles.asSequence().map { gameInfo.tileMap[it] }.any { it.isCityCenter() && it.getOwner()!=civInfo })
displayTutorials("EnemyCity") displayTutorials("EnemyCity")
if("Enables construction of Spaceship parts" in civInfo.getBuildingUniques()) if("Enables construction of Spaceship parts" in civInfo.getBuildingUniques())
displayTutorials("ApolloProgram") displayTutorials("ApolloProgram")