From 42a0e2e771ccfc931557a6cc87272a0636669998 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 12 May 2019 19:29:02 +0300 Subject: [PATCH] Continuation of d2541e6, to better fit coding standards (everything worked fine) I reallly like the way you did this, so I'm making it enabled by default =D --- core/src/com/unciv/GameSettings.kt | 2 +- core/src/com/unciv/logic/civilization/CivilizationInfo.kt | 6 ++---- core/src/com/unciv/logic/map/MapUnit.kt | 1 - core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 5 +++-- .../ui/worldscreen/optionstable/WorldScreenOptionsTable.kt | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/GameSettings.kt b/core/src/com/unciv/GameSettings.kt index 5f9bd13948..7065ca0882 100644 --- a/core/src/com/unciv/GameSettings.kt +++ b/core/src/com/unciv/GameSettings.kt @@ -5,7 +5,7 @@ import com.unciv.logic.GameSaver class GameSettings { var showWorkedTiles: Boolean = false var showResourcesAndImprovements: Boolean = true - var checkForDueUnits: Boolean = false + var checkForDueUnits: Boolean = true var language: String = "English" var resolution: String = "1050x700" var tutorialsShown = ArrayList() diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 64c6c3f2c8..8e7e29ac7b 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -300,14 +300,12 @@ class CivilizationInfo { units=newList } - fun getDueUnits() = getCivUnits().filter { it.due } - - fun hasDueUnits() = getDueUnits().isNotEmpty() + fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() } fun shouldOpenTechPicker() = tech.freeTechs != 0 || tech.currentTechnology()==null && cities.isNotEmpty() - fun shouldGoToDueUnit() = UnCivGame.Current.settings.checkForDueUnits && hasDueUnits() + fun shouldGoToDueUnit() = UnCivGame.Current.settings.checkForDueUnits && getDueUnits().isNotEmpty() fun getNextDueUnit(selectedUnit: MapUnit?): MapUnit? { val dueUnits = getDueUnits() diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 2a8ea724d1..a92b158027 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -36,7 +36,6 @@ class MapUnit { var attacksThisTurn = 0 var promotions = UnitPromotions() var due: Boolean = true - get() = field && isIdle() //region pure functions fun clone(): MapUnit { diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index ea4efe0d33..c1931ed4d4 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -228,8 +228,9 @@ class WorldScreen : CameraStageBaseScreen() { // cycle through units not yet done if (currentPlayerCiv.shouldGoToDueUnit()) { - currentPlayerCiv.getNextDueUnit(bottomBar.unitTable.selectedUnit)?.let { - tileMapHolder.setCenterPosition(it.currentTile.position) + val nextDueUnit = currentPlayerCiv.getNextDueUnit(bottomBar.unitTable.selectedUnit) + if(nextDueUnit!=null) { + tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position) shouldUpdate=true return@onClick } diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt index 573e63069d..a6d0724d5e 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt @@ -51,7 +51,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){ else addButton("Show") { settings.showResourcesAndImprovements = true; update() } add("Check for idle units".toLabel()) - addButton(if(settings.checkForDueUnits) "Yes" else "No") { + addButton(if(settings.checkForDueUnits) "Yes".tr() else "No".tr()) { settings.checkForDueUnits = !settings.checkForDueUnits update() }