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
This commit is contained in:
SomeTroglodyte 2024-02-24 21:42:31 +01:00 committed by GitHub
parent dd1f0142f1
commit 4a138478f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View File

@ -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":"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":"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":"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":"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\"."}, {"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\"."},

View File

@ -24,6 +24,7 @@ import com.unciv.ui.components.extensions.toGroup
import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.extensions.toLabel
import com.unciv.ui.components.fonts.Fonts import com.unciv.ui.components.fonts.Fonts
import com.unciv.ui.components.input.onClick 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.components.widgets.BorderedTable
import com.unciv.ui.images.ImageGetter import com.unciv.ui.images.ImageGetter
import com.unciv.ui.popups.Popup import com.unciv.ui.popups.Popup
@ -526,10 +527,7 @@ class CityButton(val city: City, private val tileGroup: TileGroup) : Table(BaseS
// 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 { fun enterCityOrInfoPopup() {
// 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 // 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 this city belongs to you and you are not iterating though the air units
if (DebugUtils.VISIBLE_MAP || viewingPlayer.isSpectator() if (DebugUtils.VISIBLE_MAP || viewingPlayer.isSpectator()
@ -538,12 +536,20 @@ class CityButton(val city: City, private val tileGroup: TileGroup) : Table(BaseS
} else if (viewingPlayer.knows(city.civ)) { } else if (viewingPlayer.knows(city.civ)) {
foreignCityInfoPopup() 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) {
enterCityOrInfoPopup()
} else { } else {
moveButtonDown() moveButtonDown()
if ((unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) && belongsToViewingCiv()) if ((unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f) && belongsToViewingCiv())
unitTable.citySelected(city) unitTable.citySelected(city)
} }
} }
onRightClick(action = ::enterCityOrInfoPopup)
// when deselected, move city button to its original position // when deselected, move city button to its original position
if (unitTable.selectedCity != city if (unitTable.selectedCity != city