More espionage UI improvements (#11584)

* Renamed "conducting counter-intelligence" to "counter-intelligence"

* Created translations for spy actions

* Clicking on the spy icon selects the spy to be moved

* Fixed spaces in template.properties

* Removed extra translations
This commit is contained in:
Oskar Niesen 2024-05-14 03:01:10 -05:00 committed by GitHub
parent 04423be44f
commit 8227c2f339
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 19 deletions

View File

@ -25,7 +25,7 @@ enum class SpyAction(val displayString: String, val hasTurns: Boolean, internal
RiggingElections("Rigging Elections", false, true) { RiggingElections("Rigging Elections", false, true) {
override fun isDoingWork(spy: Spy) = !spy.civInfo.isAtWarWith(spy.getCity().civ) override fun isDoingWork(spy: Spy) = !spy.civInfo.isAtWarWith(spy.getCity().civ)
}, },
CounterIntelligence("Conducting Counter-intelligence", false, true) { CounterIntelligence("Counter-intelligence", false, true) {
override fun isDoingWork(spy: Spy) = spy.turnsRemainingForAction > 0 override fun isDoingWork(spy: Spy) = spy.turnsRemainingForAction > 0
}, },
Dead("Dead", true, false), Dead("Dead", true, false),

View File

@ -42,6 +42,7 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
// if the value == null, this means the Spy Hideout. // if the value == null, this means the Spy Hideout.
private var moveSpyHereButtons = hashMapOf<MoveToCityButton, City?>() private var moveSpyHereButtons = hashMapOf<MoveToCityButton, City?>()
private var moveSpyButtons = hashMapOf<Spy, TextButton>()
/** Readability shortcut */ /** Readability shortcut */
private val manager get() = civInfo.espionageManager private val manager get() = civInfo.espionageManager
@ -72,6 +73,7 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
private fun updateSpyList() { private fun updateSpyList() {
spySelectionTable.clear() spySelectionTable.clear()
moveSpyButtons.clear()
spySelectionTable.add("Spy".toLabel()) spySelectionTable.add("Spy".toLabel())
spySelectionTable.add("Rank".toLabel()) spySelectionTable.add("Rank".toLabel())
spySelectionTable.add("Location".toLabel()) spySelectionTable.add("Location".toLabel())
@ -86,30 +88,14 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
val moveSpyButton = "Move".toTextButton() val moveSpyButton = "Move".toTextButton()
moveSpyButton.onClick { moveSpyButton.onClick {
if (selectedSpyButton == moveSpyButton) { onSpyClicked(moveSpyButton, spy)
resetSelection()
return@onClick
}
resetSelection()
selectedSpyButton = moveSpyButton
selectedSpy = spy
selectedSpyButton!!.label.setText(Constants.cancel.tr())
for ((button, city) in moveSpyHereButtons) {
if (city == spy.getCityOrNull()) {
button.isVisible = true
button.setDirection(Align.right)
} else {
button.isVisible = city == null // hideout
|| !city.espionage.hasSpyOf(civInfo)
button.setDirection(Align.left)
}
}
} }
if (!worldScreen.canChangeState || !spy.isAlive()) { if (!worldScreen.canChangeState || !spy.isAlive()) {
// Spectators aren't allowed to move the spies of the Civs they are viewing // Spectators aren't allowed to move the spies of the Civs they are viewing
moveSpyButton.disable() moveSpyButton.disable()
} }
spySelectionTable.add(moveSpyButton).pad(5f, 10f, 5f, 20f).row() spySelectionTable.add(moveSpyButton).pad(5f, 10f, 5f, 20f).row()
moveSpyButtons[spy] = moveSpyButton
} }
} }
@ -181,6 +167,10 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
starTable.add(star).size(8f).pad(1f).row() starTable.add(star).size(8f).pad(1f).row()
} }
add(starTable).center().padLeft(-4f) add(starTable).center().padLeft(-4f)
onClick {
onSpyClicked(moveSpyButtons[spy]!!, spy)
}
} }
private fun getSpyIcons(spies: Iterable<Spy>) = Table().apply { private fun getSpyIcons(spies: Iterable<Spy>) = Table().apply {
@ -212,6 +202,27 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
} }
} }
private fun onSpyClicked(moveSpyButton: TextButton, spy: Spy) {
if (selectedSpyButton == moveSpyButton) {
resetSelection()
return
}
resetSelection()
selectedSpyButton = moveSpyButton
selectedSpy = spy
selectedSpyButton!!.label.setText(Constants.cancel.tr())
for ((button, city) in moveSpyHereButtons) {
if (city == spy.getCityOrNull()) {
button.isVisible = true
button.setDirection(Align.right)
} else {
button.isVisible = city == null // hideout
|| !city.espionage.hasSpyOf(civInfo)
button.setDirection(Align.left)
}
}
}
private fun resetSelection() { private fun resetSelection() {
selectedSpy = null selectedSpy = null
selectedSpyButton?.label?.setText("Move".tr()) selectedSpyButton?.label?.setText("Move".tr())