From 5033cca9c2172e808c6e5bdae0cad15147b53c3d Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Wed, 15 Apr 2020 22:34:01 +0200 Subject: [PATCH] Next turn button had a dead color assignment statement (#2403) Color goes to Label instead of container String comparison special casing eliminated Clearer code structure Chose different colors - from standard palette but close to associated stat Co-authored-by: Yair Morgenstern --- .../com/unciv/ui/worldscreen/WorldScreen.kt | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 6124b11881..6e69764560 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -496,14 +496,14 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { } } - class NextTurnAction(val text:String,val action:()->Unit) + private class NextTurnAction(val text:String, val color:Color, val action:()->Unit) private fun updateNextTurnButton(isSomethingOpen: Boolean) { val action:NextTurnAction = getNextTurnAction() nextTurnAction = action.action nextTurnButton.setText(action.text.tr()) - nextTurnButton.color = if (action.text == "Next turn") Color.WHITE else Color.GRAY + nextTurnButton.label.color = action.color nextTurnButton.pack() nextTurnButton.isEnabled = !isSomethingOpen && isPlayersTurn && !waitingForAutosave nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f) @@ -514,39 +514,42 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { private fun getNextTurnAction(): NextTurnAction { return when { - !isPlayersTurn -> NextTurnAction("Waiting for other players...") {} + !isPlayersTurn -> NextTurnAction("Waiting for other players...", Color.GRAY) {} - viewingCiv.shouldGoToDueUnit() -> NextTurnAction("Next unit") { - val nextDueUnit = viewingCiv.getNextDueUnit() - if (nextDueUnit != null) { - mapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false) - bottomUnitTable.selectedCity = null - bottomUnitTable.selectedUnit = nextDueUnit - shouldUpdate = true + viewingCiv.shouldGoToDueUnit() -> + NextTurnAction("Next unit", Color.LIGHT_GRAY) { + val nextDueUnit = viewingCiv.getNextDueUnit() + if (nextDueUnit != null) { + mapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false) + bottomUnitTable.selectedCity = null + bottomUnitTable.selectedUnit = nextDueUnit + shouldUpdate = true + } } - } viewingCiv.cities.any { it.cityConstructions.currentConstruction == "" } -> - NextTurnAction("Pick construction") { + NextTurnAction("Pick construction", Color.CORAL) { val cityWithNoProductionSet = viewingCiv.cities .firstOrNull { it.cityConstructions.currentConstruction == "" } if (cityWithNoProductionSet != null) game.setScreen(CityScreen(cityWithNoProductionSet)) } - viewingCiv.shouldOpenTechPicker() -> NextTurnAction("Pick a tech") { - game.setScreen(TechPickerScreen(viewingCiv.tech.freeTechs != 0, viewingCiv)) - } + viewingCiv.shouldOpenTechPicker() -> + NextTurnAction("Pick a tech", Color.SKY) { + game.setScreen(TechPickerScreen(viewingCiv.tech.freeTechs != 0, viewingCiv)) + } viewingCiv.policies.shouldOpenPolicyPicker || (viewingCiv.policies.freePolicies > 0 && viewingCiv.policies.canAdoptPolicy()) -> - NextTurnAction("Pick a policy") { + NextTurnAction("Pick a policy", Color.VIOLET) { game.setScreen(PolicyPickerScreen(this)) viewingCiv.policies.shouldOpenPolicyPicker = false } - else -> NextTurnAction("Next turn") { - game.settings.addCompletedTutorialTask("Pass a turn") - nextTurn() - } + else -> + NextTurnAction("Next turn", Color.WHITE) { + game.settings.addCompletedTutorialTask("Pass a turn") + nextTurn() + } } }