diff --git a/android/assets/jsons/Translations/Notifications.json b/android/assets/jsons/Translations/Notifications.json index 77bd4741..82885c5b 100644 --- a/android/assets/jsons/Translations/Notifications.json +++ b/android/assets/jsons/Translations/Notifications.json @@ -408,5 +408,11 @@ Portuguese:"Encontramos um estoque de [quantidade] de ouro nas ruĂ­nas!" } + "[unit] finished exploring.": { + "German": "[unit] hat die Erkundung abgeschlossen." + }, + "[unit] has no work to do.": { + "German": "[unit] hat keine Arbeit mehr." + } } diff --git a/core/src/com/unciv/logic/automation/UnitAutomation.kt b/core/src/com/unciv/logic/automation/UnitAutomation.kt index 0e901060..34ed8778 100644 --- a/core/src/com/unciv/logic/automation/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/UnitAutomation.kt @@ -1,5 +1,6 @@ package com.unciv.logic.automation +import com.badlogic.gdx.graphics.Color import com.unciv.Constants import com.unciv.UnCivGame import com.unciv.logic.battle.* @@ -9,6 +10,7 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus import com.unciv.logic.map.MapUnit import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.tr import com.unciv.ui.worldscreen.unit.UnitAction import com.unciv.ui.worldscreen.unit.UnitActions @@ -439,6 +441,7 @@ class UnitAutomation{ return } } + unit.civInfo.addNotification("[${unit.name.tr()}] finished exploring.".tr(), unit.currentTile.position, Color.GRAY) } } \ No newline at end of file diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index 1ac4a201..7167720e 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -1,5 +1,6 @@ package com.unciv.logic.automation +import com.badlogic.gdx.graphics.Color import com.unciv.Constants import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.BFS @@ -8,6 +9,7 @@ import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tile.TileImprovement +import com.unciv.models.gamebasics.tr class WorkerAutomation(val unit: MapUnit) { @@ -40,6 +42,9 @@ class WorkerAutomation(val unit: MapUnit) { } if(tile.improvementInProgress!=null) return // we're working! if(tryConnectingCities()) return //nothing to do, try again to connect cities + + unit.civInfo.addNotification("[${unit.name.tr()}] has no work to do.".tr(), unit.currentTile.position, Color.GRAY) + } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 57c648af..03629d9b 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -310,8 +310,7 @@ class CivilizationInfo { fun shouldGoToDueUnit() = UnCivGame.Current.settings.checkForDueUnits && getDueUnits().isNotEmpty() - fun getNextDueUnit(selectedUnit: MapUnit?): MapUnit? { - selectedUnit?.due = false + fun getNextDueUnit(): MapUnit? { val dueUnits = getDueUnits() if(dueUnits.isNotEmpty()) { val unit = dueUnits[0] diff --git a/core/src/com/unciv/logic/civilization/Notification.kt b/core/src/com/unciv/logic/civilization/Notification.kt index 1320de7a..0728c380 100644 --- a/core/src/com/unciv/logic/civilization/Notification.kt +++ b/core/src/com/unciv/logic/civilization/Notification.kt @@ -5,14 +5,14 @@ import com.badlogic.gdx.math.Vector2 class Notification { var text: String = "" - var locations: List = listOf() + var locations: ArrayList = ArrayList() var color: Color = Color.BLACK internal constructor() // Needed for json deserialization - constructor(text: String, location: List = listOf(), color: Color) { + constructor(text: String, locations: List = ArrayList(), color: Color) { this.text = text - this.locations = location + this.locations = ArrayList(locations) this.color = color } } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 1c9c8d35..fd400c1e 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -209,6 +209,8 @@ open class TileInfo { } + fun hasImprovementInProgress() = improvementInProgress!=null + fun hasViewableResource(civInfo: CivilizationInfo): Boolean { return resource != null && (getTileResource().revealedBy == null || civInfo.tech.isResearched(getTileResource().revealedBy!!)) } diff --git a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt index 6979edc0..b5eb3648 100644 --- a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt @@ -12,7 +12,7 @@ import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.onClick import com.unciv.ui.utils.setFontColor -class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() { +class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerScreen() { private var selectedImprovement: TileImprovement? = null init { @@ -23,6 +23,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() { rightSideButton.onClick { tileInfo.startWorkingOnImprovement(selectedImprovement!!, currentPlayerCiv) if(tileInfo.civilianUnit!=null) tileInfo.civilianUnit!!.action=null // this is to "wake up" the worker if it's sleeping + onAccept() game.setWorldScreen() dispose() } diff --git a/core/src/com/unciv/ui/saves/LoadScreen.kt b/core/src/com/unciv/ui/saves/LoadScreen.kt index 217ebd3c..445c461d 100644 --- a/core/src/com/unciv/ui/saves/LoadScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadScreen.kt @@ -73,6 +73,7 @@ class LoadScreen : PickerScreen() { UnCivGame.Current.loadGame(loadedGame) }catch (ex:Exception){ errorLabel.setText("Could not load game from clipboard!".tr()) + ex.printStackTrace() } } @@ -101,6 +102,7 @@ class LoadScreen : PickerScreen() { popup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row() popup.addGoodSizedLabel("I could maybe help you figure out what went wrong, since this isn't supposed to happen!").row() popup.open() + ex.printStackTrace() } } diff --git a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt index ae30787e..88833d06 100644 --- a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt @@ -28,7 +28,8 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu listItem.background(ImageGetter.getDrawable("OtherIcons/civTableBackground.png")) listItem.add(label).pad(5f).padRight(10f) - // using a larger click area to avoid miss-clicking in between the messages on the map + // using a large click area with no gap in between each message item. + // this avoids accidentally clicking in between the messages, resulting in a map click val clickArea = Table().apply { add(listItem).pad(3f) touchable = Touchable.enabled diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 36ec1436..543f2f4f 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -228,12 +228,12 @@ class WorldScreen : CameraStageBaseScreen() { // cycle through units not yet done if (currentPlayerCiv.shouldGoToDueUnit()) { - val nextDueUnit = currentPlayerCiv.getNextDueUnit(bottomBar.unitTable.selectedUnit) + val nextDueUnit = currentPlayerCiv.getNextDueUnit() if(nextDueUnit!=null) { tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position) shouldUpdate=true - return@onClick } + return@onClick } if (currentPlayerCiv.shouldOpenTechPicker()) { diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 1feff44c..ad4a933f 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -158,7 +158,11 @@ class BattleTable(val worldScreen: WorldScreen): Table() { } } - if(attackableEnemy == null) attackButton.disable() + if (attackableEnemy == null) { + attackButton.disable() + attackButton.label.color = Color.GRAY + } + else { attackButton.onClick { try { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index fda6042c..8f44f652 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -39,16 +39,20 @@ class UnitActions { } } - if(!unit.isFortified() && (!unit.canFortify() || unit.health<100) && unit.currentMovement >0 && unit.action!="Set Up") { + val workingOnImprovement = unit.hasUnique("Can build improvements on tiles") && unit.currentTile.hasImprovementInProgress() + if(!unit.isFortified() && (!unit.canFortify() || unit.health<100) && unit.currentMovement >0 + && unit.action!="Set Up" && !workingOnImprovement) { val sleeping = unit.action == "Sleep" actionList += UnitAction("Sleep", !sleeping, sleeping) { unit.action = "Sleep" + unitTable.selectedUnit = null } } if(unit.canFortify()) { actionList += UnitAction("Fortify", unit.currentMovement >0) { unit.action = "Fortify 0" + unitTable.selectedUnit = null }.sound("fortify") } else if (unit.isFortified()) { actionList += UnitAction( @@ -126,9 +130,10 @@ class UnitActions { unit.action="Set Up" // setting up uses up all movement points // this is to avoid problems with the idle state: - // - it should not be idle when setting up right now - // - it should be idle when set up in the past + // - unit should not be idle when setting up right now + // - unit should be idle when set up in the past unit.currentMovement=0f + unitTable.selectedUnit = null }.sound("setup") } @@ -150,8 +155,9 @@ class UnitActions { actionList += UnitAction("Construct improvement", unit.currentMovement >0 && !tile.isCityCenter() - && GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) } - ) { worldScreen.game.screen = ImprovementPickerScreen(tile) } + && GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }, + currentAction = unit.currentTile.hasImprovementInProgress() + ) { worldScreen.game.screen = ImprovementPickerScreen(tile) { unitTable.selectedUnit = null } } if("automation" == unit.action){ actionList += UnitAction("Stop automation", true) {unit.action = null} diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index f5f17b0b..9cce6bed 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -71,6 +71,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ separator= addSeparator().actor!! add(promotionsTable).colspan(2).row() add(unitDescriptionTable) + touchable = Touchable.enabled + onClick { + selectedUnit?.currentTile?.position?.let { + worldScreen.tileMapHolder.setCenterPosition(it) + } + } }).expand() add(nextIdleUnitButton)