Added "GetUnitIcon" function, added icons in GreatPersonPickerScreen

This commit is contained in:
Yair Morgenstern 2018-05-24 22:55:11 +03:00
parent 2f6139e38d
commit 2570c4fd3d
4 changed files with 22 additions and 11 deletions

View File

@ -1,11 +1,13 @@
package com.unciv.ui.pickerscreens
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.unciv.UnCivGame
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.Unit
import com.unciv.ui.cityscreen.addClickListener
import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.ImageGetter
class GreatPersonPickerScreen : PickerScreen() {
private var theChosenOne: Unit? = null
@ -14,7 +16,12 @@ class GreatPersonPickerScreen : PickerScreen() {
closeButton.isVisible=false
rightSideButton.setText("Choose a free great person")
for (unit in GameBasics.Units.values.filter { it.name.startsWith("Great") }) {
val button = TextButton(unit.name, CameraStageBaseScreen.skin)
val button = Button(skin)
button.add(ImageGetter.getUnitIcon(unit.name)).size(30f).pad(10f)
button.add(Label(unit.name, skin).apply { style = Label.LabelStyle(style).apply { fontColor= Color.WHITE} })
.pad(10f)
button.pack()
button.addClickListener {
theChosenOne = unit
pick("Get " +unit.name)

View File

@ -252,7 +252,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
private fun getUnitImage(unit: MapUnit, color:Color): Group {
val unitBaseImage = ImageGetter.getImage("UnitIcons/${unit.name}.png")
val unitBaseImage = ImageGetter.getUnitIcon(unit.name)
.apply { setSize(15f,15f) }
val background = if(unit.isFortified()) ImageGetter.getImage("OtherIcons/Shield.png")

View File

@ -41,5 +41,9 @@ object ImageGetter {
return getImage("StatIcons/20x" + name + "5.png")
}
fun getUnitIcon(unitName:String):Image{
return getImage("UnitIcons/$unitName.png")
}
fun getBlue() = Color(0x004085bf)
}

View File

@ -20,17 +20,17 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
"Move unit" -> return ImageGetter.getStatIcon("Movement")
"Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED }
"Fortify" -> return ImageGetter.getImage("OtherIcons/Shield.png").apply { color= Color.BLACK }
"Construct improvement" -> return ImageGetter.getImage("UnitIcons/Worker.png")
"Automate" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png")
"Construct improvement" -> return ImageGetter.getUnitIcon("Worker")
"Automate" -> return ImageGetter.getUnitIcon("Great Engineer")
"Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop.png")
"Found city" -> return ImageGetter.getImage("UnitIcons/Settler.png")
"Discover Technology" -> return ImageGetter.getImage("UnitIcons/Great Scientist.png")
"Found city" -> return ImageGetter.getUnitIcon("Settler")
"Discover Technology" -> return ImageGetter.getUnitIcon("Great Scientist")
"Construct Academy" -> return ImageGetter.getImage("ImprovementIcons/Academy_(Civ5).png")
"Start Golden Age" -> return ImageGetter.getImage("UnitIcons/Great Artist.png")
"Start Golden Age" -> return ImageGetter.getUnitIcon("Great Artist")
"Construct Landmark" -> return ImageGetter.getImage("ImprovementIcons/Landmark_(Civ5).png")
"Hurry Wonder" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png")
"Hurry Wonder" -> return ImageGetter.getUnitIcon("Great Engineer")
"Construct Manufactory" -> return ImageGetter.getImage("ImprovementIcons/Manufactory_(Civ5).png")
"Conduct Trade Mission" -> return ImageGetter.getImage("UnitIcons/Great Merchant.png")
"Conduct Trade Mission" -> return ImageGetter.getUnitIcon("Great Merchant")
"Construct Customs House" -> return ImageGetter.getImage("ImprovementIcons/Customs_house_(Civ5).png")
else -> return ImageGetter.getImage("OtherIcons/Star.png")
}