"Jump To Destination" Unit Action Button for units that are moving (#9955)

* Added "Jump To Destination" UnitActionButton for moving unit

This commit also fixes the situation where the player is unable to open the Show More unit actions list while the unit is moving and out of moves for the turn. Previously, clicking Show More in this scenario would jump to the next active unit.

* Added Jump To Destination to translation file

* Changed Jump to Destination to Show Unit Destination, updated icon, credits
This commit is contained in:
Brian 2023-08-30 16:39:16 -04:00 committed by GitHub
parent 7952366afb
commit a6142ec482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 4 deletions

View File

@ -1292,6 +1292,13 @@ UnitActionIcons/StopMove
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/ShowUnitDestination
rotate: false
xy: 980, 0
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitActionIcons/Swap
rotate: false
xy: 1702, 646

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 KiB

After

Width:  |  Height:  |  Size: 1021 KiB

View File

@ -1067,6 +1067,7 @@ Range =
XP =
Move unit =
Stop movement =
Show unit destination =
Swap units =
Construct improvement =
Automate =

View File

@ -18,7 +18,7 @@ open class UnitAction(
val title: String = type.value,
val isCurrentAction: Boolean = false,
val uncivSound: UncivSound = type.uncivSound,
/** Action is Null is this unit *can* execute the action but *not right now* - it's embarked, out of moves, etc */
/** Action is Null if this unit *can* execute the action but *not right now* - it's embarked, out of moves, etc */
val action: (() -> Unit)? = null
) {
fun getIcon(): Actor {
@ -103,6 +103,8 @@ enum class UnitActionType(
{ ImageGetter.getUnitActionPortrait("Stop") }, false),
StopMovement("Stop movement",
{ ImageGetter.getUnitActionPortrait("StopMove") }, false),
ShowUnitDestination("Show unit destination",
{ ImageGetter.getUnitActionPortrait("ShowUnitDestination")}, false),
Sleep("Sleep",
{ ImageGetter.getUnitActionPortrait("Sleep") }),
SleepUntilHealed("Sleep until healed",

View File

@ -90,6 +90,7 @@ enum class KeyboardBinding(
Automate(Category.UnitActions, 'm'),
StopAutomation(Category.UnitActions,"Stop automation", 'm'),
StopMovement(Category.UnitActions,"Stop movement", '.'),
ShowUnitDestination(Category.UnitActions, "Show unit destination", 'j'),
Sleep(Category.UnitActions, 'f'),
SleepUntilHealed(Category.UnitActions,"Sleep until healed", 'h'),
Fortify(Category.UnitActions, 'f'),

View File

@ -60,8 +60,9 @@ object UnitActions {
addTriggerUniqueActions(unit, actionList)
addAddInCapitalAction(unit, actionList, tile)
if (unit.isMoving())
if (unit.isMoving()) {
actionList += UnitAction(UnitActionType.StopMovement) { unit.action = null }
}
if (unit.isExploring())
actionList += UnitAction(UnitActionType.StopExploration) { unit.action = null }
if (unit.isAutomated())
@ -87,6 +88,11 @@ object UnitActions {
val tile = unit.getTile()
val actionList = ArrayList<UnitAction>()
if (unit.isMoving()) {
actionList += UnitAction(UnitActionType.ShowUnitDestination) {
GUI.getMap().setCenterPosition(unit.getMovementDestination().position,true)
}
}
addSleepActions(actionList, unit, true)
addFortifyActions(actionList, unit, true)
addAutomateAction(unit, actionList, false)

View File

@ -65,12 +65,12 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
// overlay, since the user definitely wants to interact with the new unit.
worldScreen.mapHolder.removeUnitActionOverlay()
if (UncivGame.Current.settings.autoUnitCycle
&& (unit.isDestroyed || unitAction.type.isSkippingToNextUnit || unit.currentMovement == 0f)) {
&& (unit.isDestroyed || (unit.isMoving() && unit.currentMovement == 0f && unitAction.type.isSkippingToNextUnit) || (!unit.isMoving() && unitAction.type.isSkippingToNextUnit))) {
worldScreen.switchToNextUnit()
}
}
}
return actionButton
return actionButton
}
}

View File

@ -730,6 +730,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
- [Keyboard](https://thenounproject.com/icon/keyboard-2685534/) by Twenty Foo Studio for Options Keys
- [charts](https://thenounproject.com/icon/charts-2312023/) by Srinivas Agra (gimped to appear bolder) for the Charts page
- [framed image](https://thenounproject.com/icon/framed-image-2332187/) by Jose Dean for Victory Illustrations page
- [down](https://thenounproject.com/icon/down-39378/) by Cengiz SARI for Show unit destination
### Main menu