From 4a138478f6ffa31869b9fc74071f9e9e8835c1d5 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:42:31 +0100 Subject: [PATCH] Right-click/longpress for World screen city buttons (#10771) * City buttons support right-click / long-press to enter CityScreen directly * City r-click: Rename helper and UI tips * City capitalization follows getCurrentTutorialTask precedent * City capitalization change applied to existing translation keys * Revert "City capitalization change applied to existing translation keys" This reverts commit c3638a0daf4a9fba7d70c8f5d8428fc96ba583b3. * Revert "City capitalization follows getCurrentTutorialTask precedent" This reverts commit b618f4cae3648c0f0eaa620fa72460b794f26ebf. * City capitalization in new text follows getCurrentTutorialTask precedent --- android/assets/jsons/Tutorials.json | 3 +++ .../ui/components/tilegroups/CityButton.kt | 22 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/android/assets/jsons/Tutorials.json b/android/assets/jsons/Tutorials.json index 3c72091510..f5b1a2c0da 100644 --- a/android/assets/jsons/Tutorials.json +++ b/android/assets/jsons/Tutorials.json @@ -465,6 +465,9 @@ {"text":"On the World screen, swipe the notification list to the right to temporarily hide it. Click the \"Bell\" button to display them again."}, {"text":"The default state for the notification list can be set in Options > Display > UI - Notifications on world screen."}, {}, + {"text":"Entering a city screen quickly","header":5,"color":"#fa0"}, + {"text":"You can Right-click or long press a city button on the World screen. The result is the same as tapping it twice - once to select and move the button, again to trigger a reaction: show the city screen (if the city is yours to inspect), or offer the foreign city info popup."}, + {}, {"text":"Additional controls for the construction queue","header":5,"color":"#fa0"}, {"text":"Right-click or long press a construction item to open a popup menu with additional controls, allowing to manage production of the same item in all cities, by issuing the commands from the same City screen."}, {"text":"The \"Disable\" option moves an item to a separated \"Disabled\" tab, preventing its automatic queueing by the \"Auto-assign city production\" option. To move a disabled item back to its initial place, enter again the popup menu, and choose \"Enable\"."}, diff --git a/core/src/com/unciv/ui/components/tilegroups/CityButton.kt b/core/src/com/unciv/ui/components/tilegroups/CityButton.kt index de2c8fc8a1..134de707da 100644 --- a/core/src/com/unciv/ui/components/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/components/tilegroups/CityButton.kt @@ -24,6 +24,7 @@ import com.unciv.ui.components.extensions.toGroup import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.fonts.Fonts import com.unciv.ui.components.input.onClick +import com.unciv.ui.components.input.onRightClick import com.unciv.ui.components.widgets.BorderedTable import com.unciv.ui.images.ImageGetter import com.unciv.ui.popups.Popup @@ -526,24 +527,29 @@ class CityButton(val city: City, private val tileGroup: TileGroup) : Table(BaseS // So you can click anywhere on the button to go to the city touchable = Touchable.childrenOnly + fun enterCityOrInfoPopup() { + // second tap on the button will go to the city screen + // if this city belongs to you and you are not iterating though the air units + if (DebugUtils.VISIBLE_MAP || viewingPlayer.isSpectator() + || (belongsToViewingCiv() && !tileGroup.tile.airUnits.contains(unitTable.selectedUnit))) { + GUI.pushScreen(CityScreen(city)) + } else if (viewingPlayer.knows(city.civ)) { + foreignCityInfoPopup() + } + } + onClick { // 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. if (isButtonMoved) { - // second tap on the button will go to the city screen - // if this city belongs to you and you are not iterating though the air units - if (DebugUtils.VISIBLE_MAP || viewingPlayer.isSpectator() - || (belongsToViewingCiv() && !tileGroup.tile.airUnits.contains(unitTable.selectedUnit))) { - GUI.pushScreen(CityScreen(city)) - } else if (viewingPlayer.knows(city.civ)) { - foreignCityInfoPopup() - } + enterCityOrInfoPopup() } else { moveButtonDown() if ((unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) && belongsToViewingCiv()) unitTable.citySelected(city) } } + onRightClick(action = ::enterCityOrInfoPopup) // when deselected, move city button to its original position if (unitTable.selectedCity != city