mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 07:18:57 +07:00
Separated Unit Actions to its own table, put above the bottom bar
This commit is contained in:
@ -273,7 +273,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
|
|
||||||
fun showCircle(color:Color){
|
fun showCircle(color:Color){
|
||||||
circleImage.isVisible = true
|
circleImage.isVisible = true
|
||||||
val color = Color(color)
|
val color = color.cpy()
|
||||||
color.a = 0.3f
|
color.a = 0.3f
|
||||||
circleImage.color = color
|
circleImage.color = color
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
|||||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.GameSaver
|
import com.unciv.ui.utils.GameSaver
|
||||||
|
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||||
|
|
||||||
class WorldScreen : CameraStageBaseScreen() {
|
class WorldScreen : CameraStageBaseScreen() {
|
||||||
val gameInfo = game.gameInfo
|
val gameInfo = game.gameInfo
|
||||||
@ -19,6 +20,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
internal var buttonScale = game.settings.buttonScale
|
internal var buttonScale = game.settings.buttonScale
|
||||||
private val topBar = WorldScreenTopBar(this)
|
private val topBar = WorldScreenTopBar(this)
|
||||||
val bottomBar = WorldScreenBottomBar(this)
|
val bottomBar = WorldScreenBottomBar(this)
|
||||||
|
val unitActionsTable = UnitActionsTable(this)
|
||||||
|
|
||||||
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
||||||
private val nextTurnButton = createNextTurnButton()
|
private val nextTurnButton = createNextTurnButton()
|
||||||
@ -48,6 +50,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
bottomBar.width = stage.width
|
bottomBar.width = stage.width
|
||||||
stage.addActor(bottomBar)
|
stage.addActor(bottomBar)
|
||||||
|
stage.addActor(unitActionsTable)
|
||||||
|
|
||||||
update()
|
update()
|
||||||
|
|
||||||
@ -65,13 +68,16 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
updateTechButton()
|
updateTechButton()
|
||||||
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!
|
||||||
|
|
||||||
|
unitActionsTable.update(bottomBar.unitTable.selectedUnit)
|
||||||
|
unitActionsTable.y = bottomBar.height
|
||||||
|
|
||||||
tileMapHolder.updateTiles()
|
tileMapHolder.updateTiles()
|
||||||
topBar.update()
|
topBar.update()
|
||||||
notificationsScroll.update()
|
notificationsScroll.update()
|
||||||
notificationsScroll.width = stage.width/3
|
notificationsScroll.width = stage.width/3
|
||||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTechButton() {
|
private fun updateTechButton() {
|
||||||
|
@ -14,8 +14,8 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
|
|||||||
init {
|
init {
|
||||||
|
|
||||||
add(unitTable).width(worldScreen.stage.width/3)
|
add(unitTable).width(worldScreen.stage.width/3)
|
||||||
add(battleTable).width(worldScreen.stage.width/3).fill()
|
add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third
|
||||||
add(tileInfoTable).width(worldScreen.stage.width/3)
|
add(tileInfoTable).width(worldScreen.stage.width/3).fill()
|
||||||
|
|
||||||
val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot)
|
val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot)
|
||||||
.tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
.tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
|
29
core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt
Normal file
29
core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.unciv.ui.worldscreen.unit
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.logic.map.MapUnit
|
||||||
|
import com.unciv.ui.utils.ImageGetter
|
||||||
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
|
class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
||||||
|
|
||||||
|
fun getIconForUnitAction(unitAction:String): Image {
|
||||||
|
when(unitAction){
|
||||||
|
"Move unit" -> return ImageGetter.getStatIcon("Movement")
|
||||||
|
"Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED }
|
||||||
|
|
||||||
|
else -> return ImageGetter.getImage("StatIcons/Star.png")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update(unit: MapUnit?){
|
||||||
|
clear()
|
||||||
|
if (unit == null) return
|
||||||
|
for (button in UnitActions().getUnitActionButtons(unit, worldScreen))
|
||||||
|
add(button).colspan(2).pad(5f)
|
||||||
|
.size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row()
|
||||||
|
pack()
|
||||||
|
}
|
||||||
|
}
|
@ -16,12 +16,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
var selectedUnit : MapUnit? = null
|
var selectedUnit : MapUnit? = null
|
||||||
var currentlyExecutingAction : String? = null
|
var currentlyExecutingAction : String? = null
|
||||||
|
|
||||||
private val unitActionsTable = Table()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
pad(20f)
|
pad(20f)
|
||||||
//background = tileTableBackground
|
|
||||||
|
|
||||||
add(Table().apply {
|
add(Table().apply {
|
||||||
add(prevIdleUnitButton)
|
add(prevIdleUnitButton)
|
||||||
@ -30,13 +27,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}).colspan(2)
|
}).colspan(2)
|
||||||
row()
|
row()
|
||||||
add(unitDescriptionLabel)
|
add(unitDescriptionLabel)
|
||||||
add(unitActionsTable)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
prevIdleUnitButton.update()
|
prevIdleUnitButton.update()
|
||||||
nextIdleUnitButton.update()
|
nextIdleUnitButton.update()
|
||||||
unitActionsTable.clear()
|
|
||||||
if(selectedUnit!=null)
|
if(selectedUnit!=null)
|
||||||
{
|
{
|
||||||
try{ selectedUnit!!.getTile()}
|
try{ selectedUnit!!.getTile()}
|
||||||
@ -61,18 +57,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
|
|
||||||
unitDescriptionLabel.setText(unitLabelText)
|
unitDescriptionLabel.setText(unitLabelText)
|
||||||
|
|
||||||
for (button in UnitActions().getUnitActionButtons(selectedUnit!!, worldScreen))
|
|
||||||
unitActionsTable.add(button).colspan(2).pad(5f)
|
|
||||||
.size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unitNameLabel.setText("")
|
unitNameLabel.setText("")
|
||||||
unitDescriptionLabel.setText("")
|
unitDescriptionLabel.setText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
unitActionsTable.pack()
|
|
||||||
pack()
|
pack()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tileSelected(selectedTile: TileInfo) {
|
fun tileSelected(selectedTile: TileInfo) {
|
||||||
@ -95,3 +87,4 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user