mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
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:
parent
04423be44f
commit
8227c2f339
@ -25,7 +25,7 @@ enum class SpyAction(val displayString: String, val hasTurns: Boolean, internal
|
||||
RiggingElections("Rigging Elections", false, true) {
|
||||
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
|
||||
},
|
||||
Dead("Dead", true, false),
|
||||
|
@ -42,6 +42,7 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
|
||||
|
||||
// if the value == null, this means the Spy Hideout.
|
||||
private var moveSpyHereButtons = hashMapOf<MoveToCityButton, City?>()
|
||||
private var moveSpyButtons = hashMapOf<Spy, TextButton>()
|
||||
|
||||
/** Readability shortcut */
|
||||
private val manager get() = civInfo.espionageManager
|
||||
@ -72,6 +73,7 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
|
||||
|
||||
private fun updateSpyList() {
|
||||
spySelectionTable.clear()
|
||||
moveSpyButtons.clear()
|
||||
spySelectionTable.add("Spy".toLabel())
|
||||
spySelectionTable.add("Rank".toLabel())
|
||||
spySelectionTable.add("Location".toLabel())
|
||||
@ -86,30 +88,14 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
|
||||
|
||||
val moveSpyButton = "Move".toTextButton()
|
||||
moveSpyButton.onClick {
|
||||
if (selectedSpyButton == moveSpyButton) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
onSpyClicked(moveSpyButton, spy)
|
||||
}
|
||||
if (!worldScreen.canChangeState || !spy.isAlive()) {
|
||||
// Spectators aren't allowed to move the spies of the Civs they are viewing
|
||||
moveSpyButton.disable()
|
||||
}
|
||||
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()
|
||||
}
|
||||
add(starTable).center().padLeft(-4f)
|
||||
|
||||
onClick {
|
||||
onSpyClicked(moveSpyButtons[spy]!!, spy)
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
selectedSpy = null
|
||||
selectedSpyButton?.label?.setText("Move".tr())
|
||||
|
Loading…
x
Reference in New Issue
Block a user