From f7b99541a11839e6705107c423d514d5a6a0b9b4 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 23 Jan 2022 19:04:23 +0200 Subject: [PATCH] Tech order is displayed in a much nicer, more standardized, and overall much more professional way. This is one of the small things that's been bugging me for a while --- core/src/com/unciv/ui/pickerscreens/TechButton.kt | 11 +++++++++++ .../com/unciv/ui/pickerscreens/TechPickerScreen.kt | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/pickerscreens/TechButton.kt b/core/src/com/unciv/ui/pickerscreens/TechButton.kt index b5bab9cde2..20feef8b1d 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechButton.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechButton.kt @@ -2,6 +2,7 @@ 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.Button import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.unciv.logic.civilization.TechManager @@ -9,6 +10,7 @@ import com.unciv.ui.utils.* class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(BaseScreen.skin) { val text = "".toLabel().apply { setAlignment(Align.center) } + var orderIndicator: IconCircleGroup? = null init { touchable = Touchable.enabled @@ -86,4 +88,13 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS else rightSide.add(techEnabledIcons) .minWidth(225f) } + + fun addOrderIndicator(number:Int){ + orderIndicator = number.toString().toLabel(fontSize = 18) + .apply { setAlignment(Align.center) } + .surroundWithCircle(25f, color = ImageGetter.getBlue()) + .surroundWithCircle(27f,false) + orderIndicator!!.setPosition(0f, height, Align.topLeft) + addActor(orderIndicator) + } } diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 34ad0c9e16..93a36ae172 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -163,12 +163,13 @@ class TechPickerScreen( var text = techName.tr() - if (techName == selectedTech?.name) { + if (techName == selectedTech?.name && techButton.color != currentTechColor) { techButton.color = techButton.color.cpy().lerp(Color.BLACK, 0.5f) } + techButton.orderIndicator?.remove() if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) { - text += " (" + tempTechsToResearch.indexOf(techName) + ")" + techButton.addOrderIndicator(tempTechsToResearch.indexOf(techName) + 1) } if (!civTech.isResearched(techName) || techName == Constants.futureTech)