mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-21 20:18:28 +07:00
(UX, minor) Change "took tile damage" notification to **select** the poor victim (#10471)
* Change "took tile damage" notification to select the poor victim * Convenience constructor for NotificationAction:MapUnitAction * More verbose Kdoc for MapUnitAction
This commit is contained in:
parent
accb62a0ed
commit
0d077ee099
@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.Json
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.map.mapunit.MapUnit
|
||||
import com.unciv.ui.components.MayaCalendar
|
||||
import com.unciv.ui.screens.cityscreen.CityScreen
|
||||
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
||||
@ -93,8 +94,17 @@ class MayaLongCountAction : NotificationAction {
|
||||
}
|
||||
}
|
||||
|
||||
/** A notification action that shows and selects units on the map. */
|
||||
/** A notification action that shows and selects units on the map.
|
||||
*
|
||||
* Saves and serializes only the location. Activation will select the tile which will select any unit
|
||||
* on it or cycle through selections if this NotificationAction is the only one on the Notification.
|
||||
* When the unit has been moved away, activation still shows the tile and not the unit.
|
||||
*
|
||||
* As MapUnits do not have any persistent ID differentiating them from other units of same Civ and BaseUnit,
|
||||
* this cannot be done significantly better. Should someone add a persisted UUID to MapUnit, please change this too.
|
||||
*/
|
||||
class MapUnitAction(private val location: Vector2 = Vector2.Zero) : NotificationAction {
|
||||
constructor(unit: MapUnit) : this(unit.currentTile.position)
|
||||
override fun execute(worldScreen: WorldScreen) {
|
||||
worldScreen.mapHolder.setCenterPosition(location, selectUnit = true)
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
}
|
||||
|
||||
// Point to the gifted unit, then to the other places mentioned in the message
|
||||
val unitAction = sequenceOf(MapUnitAction(placedUnit.getTile().position))
|
||||
val unitAction = sequenceOf(MapUnitAction(placedUnit))
|
||||
val notificationActions = unitAction + LocationAction(cities.city2.location, city.location)
|
||||
receivingCiv.addNotification(
|
||||
"[${civInfo.civName}] gave us a [${militaryUnit.name}] as gift near [${city.name}]!",
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.logic.map.mapunit
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.battle.MapUnitCombatant
|
||||
import com.unciv.logic.civilization.LocationAction
|
||||
import com.unciv.logic.civilization.MapUnitAction
|
||||
import com.unciv.logic.civilization.NotificationCategory
|
||||
import com.unciv.logic.civilization.NotificationIcon
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
@ -127,7 +128,7 @@ class UnitTurnManager(val unit: MapUnit) {
|
||||
)
|
||||
} else unit.civ.addNotification(
|
||||
"Our [${unit.name}] took [$tileDamage] tile damage",
|
||||
unit.currentTile.position,
|
||||
MapUnitAction(unit),
|
||||
NotificationCategory.Units,
|
||||
unit.name
|
||||
)
|
||||
|
@ -74,7 +74,7 @@ object UniqueTriggerActivation {
|
||||
|
||||
civInfo.addNotification(
|
||||
notificationText,
|
||||
MapUnitAction(placedUnit.getTile().position),
|
||||
MapUnitAction(placedUnit),
|
||||
NotificationCategory.Units,
|
||||
placedUnit.name
|
||||
)
|
||||
@ -142,7 +142,7 @@ object UniqueTriggerActivation {
|
||||
civInfo.addNotification(
|
||||
notificationText,
|
||||
sequence {
|
||||
yield(MapUnitAction(placedUnit.getTile().position))
|
||||
yield(MapUnitAction(placedUnit))
|
||||
yieldAll(LocationAction(tile?.position))
|
||||
},
|
||||
NotificationCategory.Units,
|
||||
|
Loading…
Reference in New Issue
Block a user