From 2570c4fd3d16cbb2308abeb4b9ef6112957b7c0f Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 24 May 2018 22:55:11 +0300 Subject: [PATCH] Added "GetUnitIcon" function, added icons in GreatPersonPickerScreen --- .../ui/pickerscreens/GreatPersonPickerScreen.kt | 13 ++++++++++--- core/src/com/unciv/ui/tilegroups/TileGroup.kt | 2 +- core/src/com/unciv/ui/utils/ImageGetter.kt | 4 ++++ .../unciv/ui/worldscreen/unit/UnitActionsTable.kt | 14 +++++++------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index 8564f735c3..bebc8c0141 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -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) diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 9198aa1de3..9afce63506 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -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") diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 1c907ff825..3033ff9f82 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -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) } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt index 4949a6725c..7b19e98c55 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -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") }