mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Resolved #2618 - better inter-city navigatin int eh city screen
This commit is contained in:
@ -48,6 +48,12 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
/** Displays city name, allows switching between cities - sits on BOTTOM CENTER */
|
/** Displays city name, allows switching between cities - sits on BOTTOM CENTER */
|
||||||
private var cityPickerTable = CityScreenCityPickerTable(this)
|
private var cityPickerTable = CityScreenCityPickerTable(this)
|
||||||
|
|
||||||
|
/** Button for exiting the city - sits on BOTTOM CENTER */
|
||||||
|
val exitCityButton = "Exit city".toTextButton().apply {
|
||||||
|
labelCell.pad(10f)
|
||||||
|
onClick { exit() }
|
||||||
|
}
|
||||||
|
|
||||||
/** Holds City tiles group*/
|
/** Holds City tiles group*/
|
||||||
private var tileGroups = ArrayList<CityTileGroup>()
|
private var tileGroups = ArrayList<CityTileGroup>()
|
||||||
|
|
||||||
@ -63,6 +69,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
stage.addActor(tileTable)
|
stage.addActor(tileTable)
|
||||||
stage.addActor(selectedConstructionTable)
|
stage.addActor(selectedConstructionTable)
|
||||||
stage.addActor(cityPickerTable)
|
stage.addActor(cityPickerTable)
|
||||||
|
stage.addActor(exitCityButton)
|
||||||
stage.addActor(cityInfoTable)
|
stage.addActor(cityInfoTable)
|
||||||
update()
|
update()
|
||||||
|
|
||||||
@ -87,8 +94,11 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
cityInfoTable.update()
|
cityInfoTable.update()
|
||||||
cityInfoTable.setPosition(5f, stage.height - 5f, Align.topLeft)
|
cityInfoTable.setPosition(5f, stage.height - 5f, Align.topLeft)
|
||||||
|
|
||||||
|
exitCityButton.centerX(stage)
|
||||||
|
exitCityButton.y = 10f
|
||||||
cityPickerTable.update()
|
cityPickerTable.update()
|
||||||
cityPickerTable.centerX(stage)
|
cityPickerTable.centerX(stage)
|
||||||
|
cityPickerTable.setY(exitCityButton.top+10f, Align.bottom)
|
||||||
|
|
||||||
tileTable.update(selectedTile)
|
tileTable.update(selectedTile)
|
||||||
tileTable.setPosition(stage.width - 5f, 5f, Align.bottomRight)
|
tileTable.setPosition(stage.width - 5f, 5f, Align.bottomRight)
|
||||||
@ -219,4 +229,8 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateExitCityButton(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,14 +10,18 @@ import com.unciv.ui.utils.*
|
|||||||
class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
clear()
|
|
||||||
val city = cityScreen.city
|
val city = cityScreen.city
|
||||||
val civInfo = city.civInfo
|
val civInfo = city.civInfo
|
||||||
|
background = ImageGetter.getRoundedEdgeTableBackground(civInfo.nation.getOuterColor())
|
||||||
|
clear()
|
||||||
|
|
||||||
if (civInfo.cities.size > 1) {
|
if (civInfo.cities.size > 1) {
|
||||||
val prevCityButton = "<".toTextButton()
|
val prevCityButton = Table() // so we gt a wider clickable area than just the image itself
|
||||||
|
val image = ImageGetter.getImage("OtherIcons/BackArrow")
|
||||||
|
image.color = civInfo.nation.getInnerColor()
|
||||||
|
prevCityButton.add(image).size(25f).pad(10f)
|
||||||
prevCityButton.onClick { cityScreen.page(-1) }
|
prevCityButton.onClick { cityScreen.page(-1) }
|
||||||
add(prevCityButton).pad(20f)
|
add(prevCityButton).pad(10f)
|
||||||
} else add()
|
} else add()
|
||||||
|
|
||||||
val cityNameTable = Table()
|
val cityNameTable = Table()
|
||||||
@ -42,7 +46,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
|||||||
cityNameTable.add(resistanceImage).size(20f).padRight(5f)
|
cityNameTable.add(resistanceImage).size(20f).padRight(5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentCityLabel = city.name.toLabel(fontSize = 30)
|
val currentCityLabel = city.name.toLabel(fontSize = 30, fontColor = civInfo.nation.getInnerColor())
|
||||||
currentCityLabel.onClick {
|
currentCityLabel.onClick {
|
||||||
val editCityNamePopup = Popup(cityScreen)
|
val editCityNamePopup = Popup(cityScreen)
|
||||||
val textArea = TextField(city.name, CameraStageBaseScreen.skin)
|
val textArea = TextField(city.name, CameraStageBaseScreen.skin)
|
||||||
@ -58,23 +62,21 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
|||||||
|
|
||||||
cityNameTable.add(currentCityLabel)
|
cityNameTable.add(currentCityLabel)
|
||||||
|
|
||||||
add(cityNameTable)
|
add(cityNameTable).width(stage.width/3)
|
||||||
|
|
||||||
|
|
||||||
if (civInfo.cities.size > 1) {
|
if (civInfo.cities.size > 1) {
|
||||||
val nextCityButton = ">".toTextButton()
|
|
||||||
|
val nextCityButton = Table() // so we gt a wider clickable area than just the image itself
|
||||||
|
val image = ImageGetter.getImage("OtherIcons/BackArrow")
|
||||||
|
image.setSize(25f,25f)
|
||||||
|
image.setOrigin(Align.center)
|
||||||
|
image.rotation = 180f
|
||||||
|
image.color = civInfo.nation.getInnerColor()
|
||||||
|
nextCityButton.add(image).size(25f).pad(10f)
|
||||||
nextCityButton.onClick { cityScreen.page(1) }
|
nextCityButton.onClick { cityScreen.page(1) }
|
||||||
add(nextCityButton).pad(20f)
|
add(nextCityButton).pad(10f)
|
||||||
} else add()
|
} else add()
|
||||||
row()
|
|
||||||
|
|
||||||
val exitCityButton = "Exit city".toTextButton()
|
|
||||||
exitCityButton.labelCell.pad(10f)
|
|
||||||
|
|
||||||
exitCityButton.onClick { cityScreen.exit() }
|
|
||||||
|
|
||||||
add(exitCityButton).pad(10f).colspan(columns)
|
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user