more ui improvements (#757)
* unit action: when an exclusive decision is made, deselect unit * clicking on the unit information in the UnitTable will show that unit + minor fixes * siege units won't show movement hints when set up, while packing up does not cost any movement points * workers: highlight button when constructing an improvement, won't sleep then * fixed broken saved game * show messages if exploring is done or WorkerAutomation is done * Revert "siege units won't show movement hints when set up, while packing up does not cost any movement points" This reverts commit b805993a
This commit is contained in:
parent
85b7607d58
commit
9ce7959d32
13 changed files with 50 additions and 15 deletions
|
@ -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."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
|
@ -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)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -5,14 +5,14 @@ import com.badlogic.gdx.math.Vector2
|
|||
|
||||
class Notification {
|
||||
var text: String = ""
|
||||
var locations: List<Vector2> = listOf()
|
||||
var locations: ArrayList<Vector2> = ArrayList()
|
||||
var color: Color = Color.BLACK
|
||||
|
||||
internal constructor() // Needed for json deserialization
|
||||
|
||||
constructor(text: String, location: List<Vector2> = listOf(), color: Color) {
|
||||
constructor(text: String, locations: List<Vector2> = ArrayList(), color: Color) {
|
||||
this.text = text
|
||||
this.locations = location
|
||||
this.locations = ArrayList(locations)
|
||||
this.color = color
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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!!))
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue