mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 19:08:48 -04:00
Merged all tables at the bottom of the screen to a single bar
This commit is contained in:
parent
4267d5b1be
commit
7155bfb927
@ -26,8 +26,7 @@ open class CameraStageBaseScreen : Screen {
|
||||
private var isTutorialShowing = false
|
||||
|
||||
init {
|
||||
stage = Stage(ExtendViewport(1000f, 600f
|
||||
), batch)// FitViewport(1000,600)
|
||||
stage = Stage(ExtendViewport(1500f, 900f), batch)// FitViewport(1000,600)
|
||||
Gdx.input.inputProcessor = stage
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
@ -21,22 +20,24 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
private val battle = Battle(worldScreen.civInfo.gameInfo)
|
||||
init{
|
||||
skin = CameraStageBaseScreen.skin
|
||||
background = ImageGetter.getDrawable(ImageGetter.WhiteDot)
|
||||
.tint(ImageGetter.getBlue())
|
||||
pad(10f)
|
||||
}
|
||||
|
||||
fun hide(){
|
||||
clear()
|
||||
background=null
|
||||
}
|
||||
|
||||
fun update() {
|
||||
if (worldScreen.unitTable.selectedUnit == null
|
||||
|| worldScreen.unitTable.selectedUnit!!.getBaseUnit().unitType == UnitType.Civilian){
|
||||
val unitTable = worldScreen.bottomBar.unitTable
|
||||
if (unitTable.selectedUnit == null
|
||||
|| unitTable.selectedUnit!!.getBaseUnit().unitType == UnitType.Civilian){
|
||||
hide()
|
||||
return
|
||||
} // no attacker
|
||||
|
||||
val attacker = MapUnitCombatant(worldScreen.unitTable.selectedUnit!!)
|
||||
val attacker = MapUnitCombatant(unitTable.selectedUnit!!)
|
||||
|
||||
if (worldScreen.tileMapHolder.selectedTile == null) return
|
||||
val selectedTile = worldScreen.tileMapHolder.selectedTile!!
|
||||
@ -118,7 +119,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
row().pad(5f)
|
||||
val attackButton = TextButton("Attack", skin)
|
||||
|
||||
val attackerDistanceToTiles = attacker.unit.getDistanceToTiles()
|
||||
attacker.unit.getDistanceToTiles()
|
||||
|
||||
val attackerCanReachDefender = UnitAutomation().getAttackableEnemies(attacker.unit)
|
||||
.contains(defender.getTile())
|
||||
@ -137,12 +138,6 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
|
||||
pack()
|
||||
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
.tint(Color(0x004085ff))
|
||||
tileTableBackground.minHeight = 0f
|
||||
tileTableBackground.minWidth = 0f
|
||||
background = tileTableBackground
|
||||
|
||||
setPosition(worldScreen.stage.width/2-width/2, 5f)
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,17 @@
|
||||
package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
|
||||
class TileInfoTable(private val worldScreen: WorldScreen, internal val civInfo: CivilizationInfo) : Table() {
|
||||
|
||||
init {
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
.tint(Color(0x004085bf))
|
||||
tileTableBackground.minHeight = 0f
|
||||
tileTableBackground.minWidth = 0f
|
||||
background = tileTableBackground
|
||||
}
|
||||
class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
|
||||
|
||||
internal fun updateTileTable(tile: TileInfo) {
|
||||
clearChildren()
|
||||
val civInfo = worldScreen.civInfo
|
||||
val stats = tile.getTileStats(civInfo)
|
||||
pad(20f)
|
||||
columnDefaults(0).padRight(10f)
|
||||
|
@ -34,7 +34,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
worldScreen.displayTutorials("TileClicked")
|
||||
|
||||
selectedTile = tileInfo
|
||||
worldScreen.unitTable.tileSelected(tileInfo)
|
||||
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
|
||||
worldScreen.update()
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
}
|
||||
}
|
||||
|
||||
if(worldScreen.unitTable.selectedUnit!=null){
|
||||
val unit = worldScreen.unitTable.selectedUnit!!
|
||||
if(worldScreen.bottomBar.unitTable.selectedUnit!=null){
|
||||
val unit = worldScreen.bottomBar.unitTable.selectedUnit!!
|
||||
tileGroups[unit.getTile()]!!.addWhiteCircleAroundUnit()
|
||||
val attackableTiles:List<TileInfo>
|
||||
when(unit.getBaseUnit().unitType){
|
||||
@ -124,7 +124,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
fun setCenterPosition(vector: Vector2) {
|
||||
val tileGroup = tileGroups.values.first { it.tileInfo.position == vector }
|
||||
selectedTile = tileGroup.tileInfo
|
||||
worldScreen.unitTable.tileSelected(selectedTile!!)
|
||||
worldScreen.bottomBar.unitTable.tileSelected(selectedTile!!)
|
||||
layout() // Fit the scroll pane to the contents - otherwise, setScroll won't work!
|
||||
// We want to center on the middle of TG (TG.getX()+TG.getWidth()/2)
|
||||
// and so the scroll position (== filter the screen starts) needs to be half a screen away
|
||||
|
@ -9,38 +9,31 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.GameSaver
|
||||
import com.unciv.ui.worldscreen.unit.UnitTable
|
||||
|
||||
class WorldScreen : CameraStageBaseScreen() {
|
||||
internal val civInfo: CivilizationInfo
|
||||
val gameInfo = game.gameInfo
|
||||
internal val civInfo: CivilizationInfo = gameInfo.getPlayerCivilization()
|
||||
|
||||
val tileMapHolder: TileMapHolder
|
||||
|
||||
internal var buttonScale = game.settings.buttonScale
|
||||
private val tileInfoTable: TileInfoTable
|
||||
private val civTable = CivStatsTable(this)
|
||||
private val topBar = WorldScreenTopBar(this)
|
||||
val bottomBar = WorldScreenBottomBar(this)
|
||||
|
||||
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
||||
private val nextTurnButton = createNextTurnButton()
|
||||
|
||||
internal val optionsTable: WorldScreenOptionsTable
|
||||
private val notificationsScroll: NotificationsScroll
|
||||
internal val unitTable = UnitTable(this)
|
||||
private val battleTable:BattleTable
|
||||
|
||||
init {
|
||||
val gameInfo = game.gameInfo
|
||||
this.civInfo = gameInfo.getPlayerCivilization()
|
||||
|
||||
battleTable = BattleTable(this)
|
||||
unitTable.setPosition(5f, 5f)
|
||||
tileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
|
||||
tileInfoTable = TileInfoTable(this, civInfo)
|
||||
|
||||
civTable.setPosition(0f, stage.height - civTable.height)
|
||||
civTable.width = stage.width
|
||||
topBar.setPosition(0f, stage.height - topBar.height)
|
||||
topBar.width = stage.width
|
||||
|
||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f,
|
||||
civTable.y - nextTurnButton.height - 10f)
|
||||
topBar.y - nextTurnButton.height - 10f)
|
||||
notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
|
||||
notificationsScroll.width = stage.width/3
|
||||
optionsTable = WorldScreenOptionsTable(this, civInfo)
|
||||
@ -50,13 +43,13 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
tileMapHolder.addTiles()
|
||||
|
||||
stage.addActor(tileMapHolder)
|
||||
stage.addActor(tileInfoTable)
|
||||
stage.addActor(civTable)
|
||||
stage.addActor(topBar)
|
||||
stage.addActor(nextTurnButton)
|
||||
stage.addActor(techButton)
|
||||
stage.addActor(notificationsScroll)
|
||||
stage.addActor(unitTable)
|
||||
stage.addActor(battleTable)
|
||||
|
||||
bottomBar.width = stage.width
|
||||
stage.addActor(bottomBar)
|
||||
|
||||
update()
|
||||
|
||||
@ -73,19 +66,14 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
}
|
||||
|
||||
updateTechButton()
|
||||
if (tileMapHolder.selectedTile != null)
|
||||
tileInfoTable.updateTileTable(tileMapHolder.selectedTile!!)
|
||||
|
||||
unitTable.update() // 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!
|
||||
tileMapHolder.updateTiles()
|
||||
civTable.update()
|
||||
topBar.update()
|
||||
notificationsScroll.update()
|
||||
notificationsScroll.width = stage.width/3
|
||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||
|
||||
|
||||
battleTable.update()
|
||||
}
|
||||
|
||||
private fun updateTechButton() {
|
||||
@ -102,7 +90,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
+ civInfo.tech.turnsToTech(civInfo.tech.currentTechnology()!!) + " turns")
|
||||
|
||||
techButton.setSize(techButton.prefWidth, techButton.prefHeight)
|
||||
techButton.setPosition(10f, civTable.y - techButton.height - 5f)
|
||||
techButton.setPosition(10f, topBar.y - techButton.height - 5f)
|
||||
}
|
||||
|
||||
private fun createNextTurnButton(): TextButton {
|
||||
@ -122,7 +110,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
}
|
||||
|
||||
game.gameInfo.nextTurn()
|
||||
unitTable.currentlyExecutingAction = null
|
||||
bottomBar.unitTable.currentlyExecutingAction = null
|
||||
GameSaver.saveGame(game.gameInfo, "Autosave")
|
||||
update()
|
||||
displayTutorials("NextTurn")
|
||||
@ -139,4 +127,5 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
game.setWorldScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
35
core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt
Normal file
35
core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt
Normal file
@ -0,0 +1,35 @@
|
||||
package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.worldscreen.unit.UnitTable
|
||||
|
||||
class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
|
||||
val unitTable = UnitTable(worldScreen)
|
||||
val battleTable = BattleTable(worldScreen)
|
||||
val tileInfoTable = TileInfoTable(worldScreen)
|
||||
|
||||
init {
|
||||
|
||||
add(unitTable).width(worldScreen.stage.width/3)
|
||||
add(battleTable).width(worldScreen.stage.width/3).fill()
|
||||
add(tileInfoTable).width(worldScreen.stage.width/3)
|
||||
|
||||
val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot)
|
||||
.tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
tileTableBackground.minHeight = 0f
|
||||
tileTableBackground.minWidth = 0f
|
||||
background = tileTableBackground
|
||||
|
||||
pack()
|
||||
}
|
||||
|
||||
fun update(selectedTile: TileInfo?){
|
||||
unitTable.update()
|
||||
battleTable.update()
|
||||
if(selectedTile!=null) tileInfoTable.updateTileTable(selectedTile)
|
||||
pack()
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ import com.unciv.ui.utils.colorFromRGB
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||
|
||||
val labelStyle = Label.LabelStyle(Label("", CameraStageBaseScreen.skin).style)
|
||||
.apply { fontColor = Color.valueOf("f5f5f5ff") }
|
@ -32,7 +32,7 @@ class UnitActions {
|
||||
|
||||
fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List<UnitAction> {
|
||||
val tile = unit.getTile()
|
||||
val unitTable = worldScreen.unitTable
|
||||
val unitTable = worldScreen.bottomBar.unitTable
|
||||
val actionList = ArrayList<UnitAction>()
|
||||
|
||||
if (unitTable.currentlyExecutingAction != "moveTo"
|
||||
|
@ -19,8 +19,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
private val unitActionsTable = Table()
|
||||
|
||||
init {
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
.tint(Color(0x004085bf))
|
||||
|
||||
pad(20f)
|
||||
//background = tileTableBackground
|
||||
add(unitLabel).pad(10f)
|
||||
|
Loading…
x
Reference in New Issue
Block a user