Added quick access to diplomacy screen with other civilizations by tapping on their city buttons. (#1774)

Implemented with @Azzurite's suggestions to match the button's behavior with the player's own city buttons:
* First tap slides the city button down so that the underlying tile is visible.
* Second tap on the button presents the diplomacy screen focused on the city's owner civ.
This commit is contained in:
ltrcao 2020-01-26 11:40:38 -08:00 committed by Yair Morgenstern
parent 24520aa00c
commit 563e1f2527
3 changed files with 21 additions and 13 deletions

View File

@ -541,13 +541,13 @@ class CivilizationInfo {
if (newAllyName != "") { if (newAllyName != "") {
val newAllyCiv = gameInfo.getCivilization(newAllyName) val newAllyCiv = gameInfo.getCivilization(newAllyName)
newAllyCiv.addNotification("We have allied with [${civName}].", Color.GREEN) newAllyCiv.addNotification("We have allied with [${civName}].", getCapital().location, Color.GREEN)
newAllyCiv.updateViewableTiles() newAllyCiv.updateViewableTiles()
newAllyCiv.updateDetailedCivResources() newAllyCiv.updateDetailedCivResources()
} }
if (oldAllyName != "") { if (oldAllyName != "") {
val oldAllyCiv = gameInfo.getCivilization(oldAllyName) val oldAllyCiv = gameInfo.getCivilization(oldAllyName)
oldAllyCiv.addNotification("We have lost alliance with [${civName}].", Color.RED) oldAllyCiv.addNotification("We have lost alliance with [${civName}].", getCapital().location, Color.RED)
oldAllyCiv.updateViewableTiles() oldAllyCiv.updateViewableTiles()
oldAllyCiv.updateDetailedCivResources() oldAllyCiv.updateDetailedCivResources()
} }

View File

@ -275,10 +275,10 @@ class DiplomacyManager() {
else influence = restingPoint else influence = restingPoint
if (getTurnsToRelationshipChange() == 1) if (getTurnsToRelationshipChange() == 1)
otherCiv().addNotification("Your relationship with [${civInfo.civName}] is about to degrade", null, Color.GOLD) otherCiv().addNotification("Your relationship with [${civInfo.civName}] is about to degrade", civInfo.getCapital().location, Color.GOLD)
if (initialRelationshipLevel >= RelationshipLevel.Friend && initialRelationshipLevel != relationshipLevel()) if (initialRelationshipLevel >= RelationshipLevel.Friend && initialRelationshipLevel != relationshipLevel())
otherCiv().addNotification("Your relationship with [${civInfo.civName}] degraded", null, Color.GOLD) otherCiv().addNotification("Your relationship with [${civInfo.civName}] degraded", civInfo.getCapital().location, Color.GOLD)
} }
private fun nextTurnFlags() { private fun nextTurnFlags() {

View File

@ -14,6 +14,7 @@ import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.CityInfo import com.unciv.logic.city.CityInfo
import com.unciv.logic.city.SpecialConstruction import com.unciv.logic.city.SpecialConstruction
import com.unciv.ui.cityscreen.CityScreen import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.trade.DiplomacyScreen
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, skin: Skin): Table(skin){ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, skin: Skin): Table(skin){
@ -61,22 +62,29 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
private fun setButtonActions() { private fun setButtonActions() {
val unitTable = tileGroup.worldScreen.bottomUnitTable val unitTable = tileGroup.worldScreen.bottomUnitTable
if (UncivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
// So you can click anywhere on the button to go to the city // So you can click anywhere on the button to go to the city
touchable = Touchable.childrenOnly touchable = Touchable.childrenOnly
onClick {
// clicking swings the button a little down to allow selection of units there. // clicking swings the button a little down to allow selection of units there.
// this also allows to target selected units to move to the city tile from elsewhere. // this also allows to target selected units to move to the city tile from elsewhere.
// second tap on the button will go to the city screen if (isButtonMoved) {
onClick { // second tap on the button will go to the city screen
if (isButtonMoved) { // if this city belongs to you
if (UncivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
UncivGame.Current.setScreen(CityScreen(city)) UncivGame.Current.setScreen(CityScreen(city))
} else { } else {
moveButtonDown() // If city doesn't belong to you, go directly to its owner's diplomacy screen.
if (unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) val screen = DiplomacyScreen(UncivGame.Current.worldScreen.viewingCiv)
tileGroup.selectCity(city) screen.updateRightSide(city.civInfo)
UncivGame.Current.setScreen(screen)
} }
} else {
moveButtonDown()
if ((unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) &&
belongsToViewingCiv())
tileGroup.selectCity(city)
} }
} }