Espionage button cancels moving spy (#11631)

* Pressing the espionage button while moving a spy on the map now deselects the spy

* Minor UnitTable whitespace removeal
This commit is contained in:
Oskar Niesen 2024-05-27 04:31:15 -05:00 committed by GitHub
parent 0412d4f143
commit 3d222ecd81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -90,6 +90,11 @@ class TechPolicyDiplomacyButtons(val worldScreen: WorldScreen) : Table(BaseScree
if (game.gameInfo!!.isEspionageEnabled()) {
espionageButton.add(ImageGetter.getImage("OtherIcons/Espionage")).size(30f).pad(15f)
espionageButtonHolder.onActivation(binding = KeyboardBinding.Espionage) {
// We want to make sure to deselect a spy in the case that the player wants to cancel moving
// the spy on the map screen by pressing this button
if (worldScreen.bottomUnitTable.selectedSpy != null) {
worldScreen.bottomUnitTable.selectSpy(null)
}
game.pushScreen(EspionageOverviewScreen(worldScreen.selectedCiv, worldScreen))
}
}

View File

@ -67,9 +67,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
// Most of the time it's the same unit with the same stats so why waste precious time?
private var selectedUnitHasChanged = false
val separator: Actor
var selectedSpy: Spy? = null
fun selectSpy(spy: Spy?) {
selectedSpy = spy
selectedCity = null
@ -252,12 +252,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
unitNameLabel.clearListeners()
unitNameLabel.setText(spy.name)
unitDescriptionTable.clear()
unitIconHolder.clear()
unitIconHolder.add (ImageGetter.getImage("OtherIcons/Spy_White").apply {
color = Color.WHITE
}).size(30f)
separator.isVisible = true
val color = when(spy.rank) {
1 -> Color.BROWN