Separated battle table height from the height of the tile and unit tables

This commit is contained in:
Yair Morgenstern
2019-02-14 23:12:35 +02:00
parent e200e9026f
commit 6de517d4d5
6 changed files with 19 additions and 16 deletions

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app" applicationId "com.unciv.app"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 28 targetSdkVersion 28
versionCode 203 versionCode 204
versionName "2.13.3" versionName "2.13.4"
} }
// Had to add this crap for Travis to build, it wanted to sign the app // Had to add this crap for Travis to build, it wanted to sign the app

View File

@ -22,6 +22,7 @@ import com.unciv.ui.pickerscreens.TechButton
import com.unciv.ui.pickerscreens.TechPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen
import com.unciv.ui.trade.DiplomacyScreen import com.unciv.ui.trade.DiplomacyScreen
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.bottombar.BattleTable
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
import com.unciv.ui.worldscreen.optionstable.PopupTable import com.unciv.ui.worldscreen.optionstable.PopupTable
import com.unciv.ui.worldscreen.unit.UnitActionsTable import com.unciv.ui.worldscreen.unit.UnitActionsTable
@ -35,6 +36,7 @@ class WorldScreen : CameraStageBaseScreen() {
private val topBar = WorldScreenTopBar(this) private val topBar = WorldScreenTopBar(this)
val bottomBar = WorldScreenBottomBar(this) val bottomBar = WorldScreenBottomBar(this)
val battleTable = BattleTable(this)
val unitActionsTable = UnitActionsTable(this) val unitActionsTable = UnitActionsTable(this)
private val techButton = Table() private val techButton = Table()
@ -74,6 +76,11 @@ class WorldScreen : CameraStageBaseScreen() {
bottomBar.width = stage.width bottomBar.width = stage.width
stage.addActor(bottomBar) stage.addActor(bottomBar)
battleTable.width = stage.width/3
battleTable.x = stage.width/3
stage.addActor(battleTable)
stage.addActor(unitActionsTable) stage.addActor(unitActionsTable)
displayTutorials("NewGame") displayTutorials("NewGame")
@ -139,6 +146,8 @@ class WorldScreen : CameraStageBaseScreen() {
updateDiplomacyButton(cloneCivilization) updateDiplomacyButton(cloneCivilization)
bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit! bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit!
battleTable.update()
minimapWrapper.update(cloneCivilization) minimapWrapper.update(cloneCivilization)
minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper

View File

@ -24,6 +24,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
fun hide(){ fun hide(){
clear() clear()
pack()
} }
fun update() { fun update() {
@ -35,6 +36,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
} else if (unitTable.selectedCity != null) { } else if (unitTable.selectedCity != null) {
attacker = CityCombatant(unitTable.selectedCity!!) attacker = CityCombatant(unitTable.selectedCity!!)
} else { } else {
hide()
return // no attacker return // no attacker
} }

View File

@ -1,5 +1,6 @@
package com.unciv.ui.worldscreen.bottombar package com.unciv.ui.worldscreen.bottombar
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Align
@ -10,9 +11,9 @@ import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.toLabel import com.unciv.ui.utils.toLabel
import com.unciv.ui.worldscreen.WorldScreen import com.unciv.ui.worldscreen.WorldScreen
class TileInfoTable(private val worldScreen: WorldScreen) : Table() { class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBaseScreen.skin) {
init{ init{
skin = CameraStageBaseScreen.skin background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
} }
internal fun updateTileTable(tile: TileInfo) { internal fun updateTileTable(tile: TileInfo) {
@ -42,5 +43,4 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
} }
return table return table
} }
} }

View File

@ -1,35 +1,26 @@
package com.unciv.ui.worldscreen.bottombar package com.unciv.ui.worldscreen.bottombar
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.worldscreen.WorldScreen import com.unciv.ui.worldscreen.WorldScreen
import com.unciv.ui.worldscreen.unit.UnitTable import com.unciv.ui.worldscreen.unit.UnitTable
class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
val unitTable = UnitTable(worldScreen) val unitTable = UnitTable(worldScreen)
val battleTable = BattleTable(worldScreen)
val tileInfoTable = TileInfoTable(worldScreen) val tileInfoTable = TileInfoTable(worldScreen)
init { init {
touchable= Touchable.enabled touchable= Touchable.enabled
add(unitTable).width(worldScreen.stage.width/3).fill() add(unitTable).width(worldScreen.stage.width/3).fill()
add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third add().width(worldScreen.stage.width/3) // empty space for the battle table
add(tileInfoTable).width(worldScreen.stage.width/3).fill() add(tileInfoTable).width(worldScreen.stage.width/3).fill()
val tileTableBackground = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
tileTableBackground.minHeight = 0f
tileTableBackground.minWidth = 0f
background = tileTableBackground
pack() pack()
} }
fun update(selectedTile: TileInfo?){ fun update(selectedTile: TileInfo?){
unitTable.update() unitTable.update()
battleTable.update()
if(selectedTile!=null) tileInfoTable.updateTileTable(selectedTile) if(selectedTile!=null) tileInfoTable.updateTileTable(selectedTile)
pack() pack()
} }

View File

@ -33,6 +33,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
init { init {
pad(5f) pad(5f)
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
add(Table().apply { add(Table().apply {
add(prevIdleUnitButton) add(prevIdleUnitButton)