diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index bebc8c0141..797b758cb9 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -8,6 +8,7 @@ import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.Unit import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.ImageGetter +import com.unciv.ui.utils.setFontColor class GreatPersonPickerScreen : PickerScreen() { private var theChosenOne: Unit? = null @@ -19,8 +20,7 @@ class GreatPersonPickerScreen : PickerScreen() { 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.add(Label(unit.name, skin).setFontColor(Color.WHITE)).pad(10f) button.pack() button.addClickListener { theChosenOne = unit diff --git a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt index 367df046cc..a07e691faa 100644 --- a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt @@ -13,6 +13,7 @@ import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.center +import com.unciv.ui.utils.setFontColor class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) { @@ -60,9 +61,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) { val cityButtonText = city.name + " (" + city.population.population + ")" val label = Label(cityButtonText, CameraStageBaseScreen.skin) - val labelStyle = Label.LabelStyle(label.style) - labelStyle.fontColor = city.civInfo.getCivilization().getColor() - label.style = labelStyle + label.setFontColor(city.civInfo.getCivilization().getColor()) if (city.civInfo.isPlayerCivilization()) label.addClickListener { UnCivGame.Current.screen = CityScreen(city) diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index cfc100b640..96848e0d29 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -115,3 +115,5 @@ fun Actor.center(parent:Actor){ centerX(parent); centerY(parent)} fun Actor.centerX(parent:Stage){ x = parent.width/2 - width/2 } fun Actor.centerY(parent:Stage){ y = parent.height/2- height/2} fun Actor.center(parent:Stage){ centerX(parent); centerY(parent)} + +fun Label.setFontColor(color:Color): Label {style=Label.LabelStyle(style).apply { fontColor=color }; return this} \ No newline at end of file diff --git a/core/src/com/unciv/ui/worldscreen/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/BattleTable.kt index a6e8c4784f..fea5e109ce 100644 --- a/core/src/com/unciv/ui/worldscreen/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/BattleTable.kt @@ -13,6 +13,7 @@ import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.disable +import com.unciv.ui.utils.setFontColor import kotlin.math.max class BattleTable(val worldScreen: WorldScreen): Table() { @@ -60,13 +61,11 @@ class BattleTable(val worldScreen: WorldScreen): Table() { clear() row().pad(5f) val attackerLabel = Label(attacker.getName(), skin) - attackerLabel.style= Label.LabelStyle(attackerLabel.style) - attackerLabel.style.fontColor=attacker.getCivilization().getCivilization().getColor() + .setFontColor(attacker.getCivilization().getCivilization().getColor()) add(attackerLabel) val defenderLabel = Label(defender.getName(), skin) - defenderLabel.style= Label.LabelStyle(defenderLabel.style) - defenderLabel.style.fontColor=defender.getCivilization().getCivilization().getColor() + .setFontColor(defender.getCivilization().getCivilization().getColor()) add(defenderLabel) row().pad(5f) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index 88a733c001..dd667b8f3b 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -9,23 +9,19 @@ import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.ResourceType import com.unciv.models.stats.Stats import com.unciv.ui.cityscreen.addClickListener -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.ImageGetter -import com.unciv.ui.utils.centerY -import com.unciv.ui.utils.colorFromRGB +import com.unciv.ui.utils.* import kotlin.math.abs import kotlin.math.ceil class WorldScreenTopBar(val screen: WorldScreen) : Table() { - val labelStyle = Label.LabelStyle(Label("", CameraStageBaseScreen.skin).style) - .apply { fontColor = Color.valueOf("f5f5f5ff") } + val labelSkin = CameraStageBaseScreen.skin - private val turnsLabel = Label("Turns: 0/400", labelStyle) - private val goldLabel = Label("Gold:", labelStyle).apply { color = colorFromRGB(225, 217, 71) } - private val scienceLabel = Label("Science:", labelStyle).apply { color = colorFromRGB(78, 140, 151) } - private val happinessLabel = Label("Happiness:", labelStyle) - private val cultureLabel = Label("Culture:", labelStyle).apply { color = colorFromRGB(210, 94, 210) } + private val turnsLabel = Label("Turns: 0/400",labelSkin) + private val goldLabel = Label("Gold:", labelSkin).setFontColor(colorFromRGB(225, 217, 71) ) + private val scienceLabel = Label("Science:", labelSkin).setFontColor(colorFromRGB(78, 140, 151) ) + private val happinessLabel = Label("Happiness:", labelSkin) + private val cultureLabel = Label("Culture:", labelSkin).setFontColor(colorFromRGB(210, 94, 210) ) private val resourceLabels = HashMap() private val resourceImages = HashMap() private val happinessImage = ImageGetter.getStatIcon("Happiness") @@ -51,7 +47,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() { val resourceImage = ImageGetter.getImage(fileName) resourceImages.put(resource.name, resourceImage) resourceTable.add(resourceImage).size(20f) - val resourceLabel = Label("0", labelStyle) + val resourceLabel = Label("0", labelSkin) resourceLabels.put(resource.name, resourceLabel) resourceTable.add(resourceLabel) } @@ -127,10 +123,10 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() { happinessLabel.setText(getHappinessText(civInfo)) if (civInfo.happiness < 0) { - happinessLabel.color = Color.valueOf("ef5350") + happinessLabel.setFontColor(Color.valueOf("ef5350")) happinessImage.drawable = ImageGetter.getStatIcon("Malcontent").drawable } else { - happinessLabel.color = colorFromRGB(92, 194, 77) + happinessLabel.setFontColor(colorFromRGB(92, 194, 77)) happinessImage.drawable = ImageGetter.getStatIcon("Happiness").drawable } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt index f22fed2130..285a4e9a9c 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -11,6 +11,7 @@ import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.disable +import com.unciv.ui.utils.setFontColor import com.unciv.ui.worldscreen.WorldScreen class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ @@ -50,7 +51,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ val actionButton = Button(CameraStageBaseScreen.skin) actionButton.add(getIconForUnitAction(unitAction.name)).size(20f).pad(5f) actionButton.add(Label(unitAction.name,CameraStageBaseScreen.skin) - .apply { style= Label.LabelStyle(style); style.fontColor = Color.WHITE }) + .setFontColor(Color.WHITE)) actionButton.pack() actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen!!.update() }) if (!unitAction.canAct) actionButton.disable()