mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
Order indicators in TechScreen like original Civ V (#8615)
This commit is contained in:
@ -11,7 +11,6 @@ import com.unciv.models.ruleset.Building
|
|||||||
import com.unciv.models.ruleset.tile.TileImprovement
|
import com.unciv.models.ruleset.tile.TileImprovement
|
||||||
import com.unciv.models.ruleset.tile.TileResource
|
import com.unciv.models.ruleset.tile.TileResource
|
||||||
import com.unciv.models.ruleset.unique.UniqueType
|
import com.unciv.models.ruleset.unique.UniqueType
|
||||||
import com.unciv.ui.images.IconCircleGroup
|
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.utils.BaseScreen
|
import com.unciv.ui.utils.BaseScreen
|
||||||
import com.unciv.ui.utils.extensions.addBorder
|
import com.unciv.ui.utils.extensions.addBorder
|
||||||
@ -20,7 +19,6 @@ import com.unciv.ui.utils.extensions.center
|
|||||||
import com.unciv.ui.utils.extensions.centerY
|
import com.unciv.ui.utils.extensions.centerY
|
||||||
import com.unciv.ui.utils.extensions.darken
|
import com.unciv.ui.utils.extensions.darken
|
||||||
import com.unciv.ui.utils.extensions.setFontSize
|
import com.unciv.ui.utils.extensions.setFontSize
|
||||||
import com.unciv.ui.utils.extensions.surroundWithCircle
|
|
||||||
import com.unciv.ui.utils.extensions.toLabel
|
import com.unciv.ui.utils.extensions.toLabel
|
||||||
|
|
||||||
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(BaseScreen.skin) {
|
class TechButton(techName:String, private val techManager: TechManager, isWorldScreen: Boolean = true) : Table(BaseScreen.skin) {
|
||||||
@ -34,7 +32,6 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
setFontSize(14)
|
setFontSize(14)
|
||||||
setAlignment(Align.right)
|
setAlignment(Align.right)
|
||||||
}
|
}
|
||||||
var orderIndicator: IconCircleGroup? = null
|
|
||||||
var bg = Image(BaseScreen.skinStrings.getUiBackground("TechPickerScreen/TechButton", BaseScreen.skinStrings.roundedEdgeRectangleMidShape))
|
var bg = Image(BaseScreen.skinStrings.getUiBackground("TechPickerScreen/TechButton", BaseScreen.skinStrings.roundedEdgeRectangleMidShape))
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -171,13 +168,4 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
.expandX().left().row()
|
.expandX().left().row()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addOrderIndicator(number:Int){
|
|
||||||
orderIndicator = number.toString().toLabel(fontSize = 18)
|
|
||||||
.apply { setAlignment(Align.center) }
|
|
||||||
.surroundWithCircle(28f, color = BaseScreen.skinStrings.skinConfig.baseColor)
|
|
||||||
.surroundWithCircle(30f,false)
|
|
||||||
orderIndicator!!.setPosition(0f, height, Align.topLeft)
|
|
||||||
addActor(orderIndicator)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.ui.pickerscreens
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
@ -24,6 +25,7 @@ import com.unciv.ui.utils.extensions.darken
|
|||||||
import com.unciv.ui.utils.extensions.disable
|
import com.unciv.ui.utils.extensions.disable
|
||||||
import com.unciv.ui.utils.extensions.onClick
|
import com.unciv.ui.utils.extensions.onClick
|
||||||
import com.unciv.ui.utils.extensions.onDoubleClick
|
import com.unciv.ui.utils.extensions.onDoubleClick
|
||||||
|
import com.unciv.ui.utils.extensions.surroundWithCircle
|
||||||
import com.unciv.ui.utils.extensions.toLabel
|
import com.unciv.ui.utils.extensions.toLabel
|
||||||
import com.unciv.utils.concurrency.Concurrency
|
import com.unciv.utils.concurrency.Concurrency
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@ -40,6 +42,7 @@ class TechPickerScreen(
|
|||||||
private var civTech: TechManager = civInfo.tech
|
private var civTech: TechManager = civInfo.tech
|
||||||
private var tempTechsToResearch: ArrayList<String>
|
private var tempTechsToResearch: ArrayList<String>
|
||||||
private var lines = ArrayList<Image>()
|
private var lines = ArrayList<Image>()
|
||||||
|
private var orderIndicators = Group()
|
||||||
private var eraLabels = ArrayList<Label>()
|
private var eraLabels = ArrayList<Label>()
|
||||||
|
|
||||||
/** We need this to be a separate table, and NOT the topTable, because *inhales*
|
/** We need this to be a separate table, and NOT the topTable, because *inhales*
|
||||||
@ -193,8 +196,7 @@ class TechPickerScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setButtonsInfo() {
|
private fun setButtonsInfo() {
|
||||||
for (techName in techNameToButton.keys) {
|
for ((techName, techButton) in techNameToButton) {
|
||||||
val techButton = techNameToButton[techName]!!
|
|
||||||
techButton.setButtonColor(when {
|
techButton.setButtonColor(when {
|
||||||
civTech.isResearched(techName) && techName != Constants.futureTech -> researchedTechColor
|
civTech.isResearched(techName) && techName != Constants.futureTech -> researchedTechColor
|
||||||
// if we're here to pick a free tech, show the current tech like the rest of the researchables so it'll be obvious what we can pick
|
// if we're here to pick a free tech, show the current tech like the rest of the researchables so it'll be obvious what we can pick
|
||||||
@ -213,11 +215,6 @@ class TechPickerScreen(
|
|||||||
techButton.setButtonColor(colorFromRGB(230, 220, 114))
|
techButton.setButtonColor(colorFromRGB(230, 220, 114))
|
||||||
}
|
}
|
||||||
|
|
||||||
techButton.orderIndicator?.remove()
|
|
||||||
if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) {
|
|
||||||
techButton.addOrderIndicator(tempTechsToResearch.indexOf(techName) + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!civTech.isResearched(techName) || techName == Constants.futureTech) {
|
if (!civTech.isResearched(techName) || techName == Constants.futureTech) {
|
||||||
techButton.turns.setText(turnsToTech[techName] + "${Fonts.turn}".tr())
|
techButton.turns.setText(turnsToTech[techName] + "${Fonts.turn}".tr())
|
||||||
}
|
}
|
||||||
@ -226,6 +223,8 @@ class TechPickerScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
addConnectingLines()
|
addConnectingLines()
|
||||||
|
|
||||||
|
addOrderIndicators()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addConnectingLines() {
|
private fun addConnectingLines() {
|
||||||
@ -369,6 +368,26 @@ class TechPickerScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addOrderIndicators() {
|
||||||
|
orderIndicators.clear()
|
||||||
|
for ((techName, techButton) in techNameToButton) {
|
||||||
|
val techButtonCoords = Vector2(0f, techButton.height / 2)
|
||||||
|
techButton.localToStageCoordinates(techButtonCoords)
|
||||||
|
techTable.stageToLocalCoordinates(techButtonCoords)
|
||||||
|
if (tempTechsToResearch.contains(techName) && tempTechsToResearch.size > 1) {
|
||||||
|
val index = tempTechsToResearch.indexOf(techName) + 1
|
||||||
|
val orderIndicator = index.toString().toLabel(fontSize = 18)
|
||||||
|
.apply { setAlignment(Align.center) }
|
||||||
|
.surroundWithCircle(28f, color = skinStrings.skinConfig.baseColor)
|
||||||
|
.surroundWithCircle(30f,false)
|
||||||
|
.apply { setPosition(techButtonCoords.x - width, techButtonCoords.y - height / 2) }
|
||||||
|
orderIndicators.addActor(orderIndicator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
techTable.addActor(orderIndicators)
|
||||||
|
orderIndicators.toFront()
|
||||||
|
}
|
||||||
|
|
||||||
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchFromWorldScreen: Boolean = true) {
|
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchFromWorldScreen: Boolean = true) {
|
||||||
|
|
||||||
val previousSelectedTech = selectedTech
|
val previousSelectedTech = selectedTech
|
||||||
|
@ -16,7 +16,7 @@ class TradeTable(private val otherCivilization: Civilization, stage: DiplomacySc
|
|||||||
var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
|
var offerColumnsTable = OfferColumnsTable(tradeLogic, stage) { onChange() }
|
||||||
// This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way
|
// This is so that after a trade has been traded, we can switch out the offersToDisplay to start anew - this is the easiest way
|
||||||
private var offerColumnsTableWrapper = Table()
|
private var offerColumnsTableWrapper = Table()
|
||||||
private val offerButton = "Offer trade".toTextButton().apply{ isEnabled = false }
|
private val offerButton = "Offer trade".toTextButton().apply { isEnabled = false }
|
||||||
|
|
||||||
private fun isTradeOffered() = otherCivilization.tradeRequests.any { it.requestingCiv == currentPlayerCiv.civName }
|
private fun isTradeOffered() = otherCivilization.tradeRequests.any { it.requestingCiv == currentPlayerCiv.civName }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user