From e39d3e89dad48ad4b72a11e9ed2069c398d927e2 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 30 Sep 2020 19:42:47 +0300 Subject: [PATCH] All specialist colors come from the json now :) --- core/src/com/unciv/ui/cityscreen/CityInfoTable.kt | 10 +++++----- .../unciv/ui/cityscreen/SpecialistAllocationTable.kt | 9 ++++++--- core/src/com/unciv/ui/utils/ImageGetter.kt | 12 ++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt index f810ca9a18..b68969ed8e 100644 --- a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt @@ -150,15 +150,15 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS addBuildingInfo(building, specialistBuildingsTable) val specialistIcons = Table() specialistIcons.row().size(20f).pad(5f) - for (stat in building.specialistSlots!!.toHashMap()) + for (stat in building.specialistSlots!!.toHashMap()) { + if (stat.value == 0f) continue + val specialist = cityInfo.getRuleset().specialists[cityInfo.population.specialistNameByStat(stat.key)]!! for (i in 0 until stat.value.toInt()) - specialistIcons.add(ImageGetter.getSpecialistIcon(stat.key)).size(20f) + specialistIcons.add(ImageGetter.getSpecialistIcon(specialist.colorObject)).size(20f) + } specialistBuildingsTable.add(specialistIcons).pad(0f).row() } - - // specialist allocation -// addCategory("Specialist Allocation", SpecialistAllocationTable(cityScreen)) todo } if (!otherBuildings.isEmpty()) { diff --git a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt index 626c76732f..ac61fedad0 100644 --- a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt +++ b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt @@ -25,7 +25,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBa val maxSpecialists = cityInfo.population.getMaxSpecialistsNew()[specialistName]!! if (cityScreen.canChangeState) add(getUnassignButton(assignedSpecialists, stat)) - add(getAllocationTable(assignedSpecialists, maxSpecialists, stat)).pad(10f) + add(getAllocationTable(assignedSpecialists, maxSpecialists, specialistName)).pad(10f) if (cityScreen.canChangeState) add(getAssignButton(assignedSpecialists, maxSpecialists, stat)) addSeparatorVertical().pad(10f) add(getSpecialistStatsTable(specialistName)).row() @@ -34,11 +34,14 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBa } - fun getAllocationTable(assignedSpecialists: Int, maxSpecialists: Int, stat: Stat):Table{ + fun getAllocationTable(assignedSpecialists: Int, maxSpecialists: Int, specialistName: String):Table{ val specialistIconTable = Table() + val specialistObject = cityInfo.getRuleset().specialists[specialistName]!! for (i in 1..maxSpecialists) { - val icon = ImageGetter.getSpecialistIcon(stat, i <= assignedSpecialists) + val color = if (i <= assignedSpecialists) specialistObject.colorObject + else Color.GRAY // unassigned + val icon = ImageGetter.getSpecialistIcon(color) specialistIconTable.add(icon).size(30f) } return specialistIconTable diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index eeb01bb8db..83950d5e02 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -303,17 +303,9 @@ object ImageGetter { return line } - fun getSpecialistIcon(stat: Stat, isFilled: Boolean =true): Image { + fun getSpecialistIcon(color:Color): Image { val specialist = getImage("StatIcons/Specialist") - if (!isFilled) specialist.color = Color.GRAY - else specialist.color = when (stat) { - Stat.Production -> Color.BROWN - Stat.Gold -> Color.GOLD - Stat.Science -> Color.BLUE - Stat.Culture -> Color.PURPLE - else -> Color.WHITE - } - + specialist.color = color return specialist } }