Switched positions of "raze city" and "exit city" buttons - "exit" is a much more common use-case, and therefore should have the more easily-reachable spot

This commit is contained in:
Yair Morgenstern 2019-02-09 22:40:52 +02:00
parent 10e9a5e481
commit d9fb3fdb2c

View File

@ -22,7 +22,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
private var cityInfoTable = CityInfoTable(this) private var cityInfoTable = CityInfoTable(this)
private var constructionsTable = ConstructionsTable(this) private var constructionsTable = ConstructionsTable(this)
private var cityPickerTable = Table() private var cityPickerTable = Table()
private var goToWorldButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin) private var razeCityButtonHolder = Table()
private var tileGroups = ArrayList<CityTileGroup>() private var tileGroups = ArrayList<CityTileGroup>()
var topCityStatsTable=Table() var topCityStatsTable=Table()
@ -46,7 +46,6 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
stage.height - buildingsTableContainer.height-5) stage.height - buildingsTableContainer.height-5)
stage.addActor(constructionsTable) stage.addActor(constructionsTable)
stage.addActor(goToWorldButton)
stage.addActor(cityPickerTable) stage.addActor(cityPickerTable)
stage.addActor(buildingsTableContainer) stage.addActor(buildingsTableContainer)
@ -58,7 +57,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
cityInfoTable.update() cityInfoTable.update()
updateCityPickerTable() updateCityPickerTable()
constructionsTable.update() constructionsTable.update()
updateGoToWorldButton() updateRazeCityButton()
updateTileTable() updateTileTable()
updateTileGroups() updateTileGroups()
@ -66,6 +65,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
topCityStatsTable = getCityStatsTable() topCityStatsTable = getCityStatsTable()
topCityStatsTable.setPosition(5f, stage.height-5-topCityStatsTable.height) topCityStatsTable.setPosition(5f, stage.height-5-topCityStatsTable.height)
stage.addActor(topCityStatsTable) stage.addActor(topCityStatsTable)
stage.addActor(topCityStatsTable)
if (city.getCenterTile().getTilesAtDistance(4).isNotEmpty()){ if (city.getCenterTile().getTilesAtDistance(4).isNotEmpty()){
displayTutorials("CityRange") displayTutorials("CityRange")
@ -180,35 +180,40 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
} else cityPickerTable.add() } else cityPickerTable.add()
cityPickerTable.row() cityPickerTable.row()
if(!city.isBeingRazed) { val exitCityButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin)
val razeCityButton = TextButton("Raze city".tr(), skin)
razeCityButton.onClick { city.isBeingRazed=true; update() }
cityPickerTable.add(razeCityButton).colspan(cityPickerTable.columns)
}
else{
val stopRazingCityButton = TextButton("Stop razing city".tr(), skin)
stopRazingCityButton.onClick { city.isBeingRazed=false; update() }
cityPickerTable.add(stopRazingCityButton).colspan(cityPickerTable.columns)
}
cityPickerTable.pack() exitCityButton.onClick {
cityPickerTable.centerX(stage)
stage.addActor(cityPickerTable)
}
private fun updateGoToWorldButton() {
goToWorldButton.clearListeners()
goToWorldButton.onClick {
game.setWorldScreen() game.setWorldScreen()
game.worldScreen.tileMapHolder.setCenterPosition(city.location) game.worldScreen.tileMapHolder.setCenterPosition(city.location)
game.worldScreen.bottomBar.unitTable.selectedUnit=null game.worldScreen.bottomBar.unitTable.selectedUnit=null
dispose() dispose()
} }
goToWorldButton.pad(5f) cityPickerTable.add(exitCityButton).colspan(cityPickerTable.columns)
cityPickerTable.pack()
cityPickerTable.centerX(stage)
stage.addActor(cityPickerTable)
}
private fun updateRazeCityButton() {
razeCityButtonHolder.clear()
if(!city.isBeingRazed) {
val razeCityButton = TextButton("Raze city".tr(), skin)
razeCityButton.onClick { city.isBeingRazed=true; update() }
razeCityButtonHolder.add(razeCityButton).colspan(cityPickerTable.columns)
}
else{
val stopRazingCityButton = TextButton("Stop razing city".tr(), skin)
stopRazingCityButton.onClick { city.isBeingRazed=false; update() }
razeCityButtonHolder.add(stopRazingCityButton).colspan(cityPickerTable.columns)
}
razeCityButtonHolder.pack()
//goToWorldButton.setSize(goToWorldButton.prefWidth, goToWorldButton.prefHeight) //goToWorldButton.setSize(goToWorldButton.prefWidth, goToWorldButton.prefHeight)
goToWorldButton.centerX(stage) razeCityButtonHolder.centerX(stage)
goToWorldButton.y = stage.height - goToWorldButton.height - 20 razeCityButtonHolder.y = stage.height - razeCityButtonHolder.height - 20
stage.addActor(razeCityButtonHolder)
} }
private fun addTiles() { private fun addTiles() {