From 7454b57e4ddb863f5edb926240174cdfb9cbbd7d Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 9 Sep 2019 23:06:17 +0300 Subject: [PATCH] Tech coloration issues --- core/src/com/unciv/Constants.kt | 1 + .../logic/automation/NextTurnAutomation.kt | 2 +- .../unciv/logic/civilization/TechManager.kt | 5 +++-- .../ui/pickerscreens/TechPickerScreen.kt | 19 ++++++++++--------- .../com/unciv/ui/worldscreen/WorldScreen.kt | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index 1cd91d051a..f1af11e7d5 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -23,6 +23,7 @@ class Constants{ val unitActionSleep = "Sleep" val unitActionAutomation = "automation" val unitActionExplore = "Explore" + val futureTech = "Future Tech" } } \ No newline at end of file diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index e489868047..28689e74be 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -174,7 +174,7 @@ class NextTurnAutomation{ val tech: Technology if (researchableTechs.isEmpty()) { // no non-researched techs available, go for future tech - civInfo.tech.techsToResearch.add("Future Tech") + civInfo.tech.techsToResearch.add(Constants.futureTech) return } diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 856db0324d..62dcad9f77 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -2,6 +2,7 @@ package com.unciv.logic.civilization import com.badlogic.gdx.graphics.Color +import com.unciv.Constants import com.unciv.logic.map.RoadStatus import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tech.Technology @@ -86,7 +87,7 @@ class TechManager { val techNameToCheck = checkPrerequisites.pop() // future tech can have been researched even when we're researching it, // so...if we skip it we'll end up with 0 techs in the "required techs", which will mean that we don't have annything to research. Yeah. - if (techNameToCheck!="Future Tech" && + if (techNameToCheck!=Constants.futureTech && (isResearched(techNameToCheck) || prerequisites.contains(techNameToCheck)) ) continue //no need to add or check prerequisites val techToCheck = GameBasics.Technologies[techNameToCheck] @@ -116,7 +117,7 @@ class TechManager { } fun addTechnology(techName:String) { - if(techName!="Future Tech") + if(techName!= Constants.futureTech) techsToResearch.remove(techName) val previousEra = civInfo.getEra() diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 401090acf5..9e7091a8d8 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane +import com.unciv.Constants import com.unciv.UnCivGame import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.TechManager @@ -121,14 +122,14 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec private fun setButtonsInfo() { for (techName in techNameToButton.keys) { val techButton = techNameToButton[techName]!! - when { - civTech.isResearched(techName) && techName!="Future Tech" -> techButton.color = researchedTechColor - tempTechsToResearch.isNotEmpty() && tempTechsToResearch.first() == techName -> techButton.color = currentTechColor - tempTechsToResearch.contains(techName) -> techButton.color = queuedTechColor - else -> techButton.color = Color.BLACK + techButton.color = when { + 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 + tempTechsToResearch.firstOrNull() == techName && !isFreeTechPick -> currentTechColor + researchableTechs.contains(techName) && !civTech.isResearched(techName) -> researchableTechColor + tempTechsToResearch.contains(techName) -> queuedTechColor + else -> Color.BLACK } - //the tech that can be selected to research immediately should be always researchableTechColor, it's very good when we pick a free tech. - if (researchableTechs.contains(techName)&&!civTech.isResearched(techName)) techButton.color = researchableTechColor var text = techName.tr() @@ -140,7 +141,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec text += " (" + tempTechsToResearch.indexOf(techName) + ")" } - if (!civTech.isResearched(techName) || techName=="Future Tech") + if (!civTech.isResearched(techName) || techName== Constants.futureTech) text += "\r\n" + turnsToTech[techName] + " {turns}".tr() techButton.text.setText(text) @@ -166,7 +167,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec return } - if (civTech.isResearched(tech.name) && tech.name != "Future Tech") { + if (civTech.isResearched(tech.name) && tech.name != Constants.futureTech) { rightSideButton.setText("Pick a tech".tr()) rightSideButton.disable() setButtonsInfo() diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index f1c976b633..fab39f496d 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -246,7 +246,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { val researchableTechs = GameBasics.Technologies.values.filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) } if (civInfo.tech.currentTechnology() == null && researchableTechs.isEmpty()) - civInfo.tech.techsToResearch.add("Future Tech") + civInfo.tech.techsToResearch.add(Constants.futureTech) if (civInfo.tech.currentTechnology() == null) { val buttonPic = Table()