mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Separated Unit Actions to its own table, put above the bottom bar
This commit is contained in:
parent
0bbb7d6254
commit
5a564f29c3
@ -273,7 +273,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
|
||||
fun showCircle(color:Color){
|
||||
circleImage.isVisible = true
|
||||
val color = Color(color)
|
||||
val color = color.cpy()
|
||||
color.a = 0.3f
|
||||
circleImage.color = color
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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.UnitActionsTable
|
||||
|
||||
class WorldScreen : CameraStageBaseScreen() {
|
||||
val gameInfo = game.gameInfo
|
||||
@ -19,6 +20,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
internal var buttonScale = game.settings.buttonScale
|
||||
private val topBar = WorldScreenTopBar(this)
|
||||
val bottomBar = WorldScreenBottomBar(this)
|
||||
val unitActionsTable = UnitActionsTable(this)
|
||||
|
||||
private val techButton = TextButton("", CameraStageBaseScreen.skin)
|
||||
private val nextTurnButton = createNextTurnButton()
|
||||
@ -48,6 +50,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
|
||||
bottomBar.width = stage.width
|
||||
stage.addActor(bottomBar)
|
||||
stage.addActor(unitActionsTable)
|
||||
|
||||
update()
|
||||
|
||||
@ -65,13 +68,16 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
|
||||
updateTechButton()
|
||||
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()
|
||||
topBar.update()
|
||||
notificationsScroll.update()
|
||||
notificationsScroll.width = stage.width/3
|
||||
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
|
||||
nextTurnButton.y - notificationsScroll.height - 5f)
|
||||
|
||||
}
|
||||
|
||||
private fun updateTechButton() {
|
||||
|
@ -14,8 +14,8 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
|
||||
init {
|
||||
|
||||
add(unitTable).width(worldScreen.stage.width/3)
|
||||
add(battleTable).width(worldScreen.stage.width/3).fill()
|
||||
add(tileInfoTable).width(worldScreen.stage.width/3)
|
||||
add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third
|
||||
add(tileInfoTable).width(worldScreen.stage.width/3).fill()
|
||||
|
||||
val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot)
|
||||
.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 currentlyExecutingAction : String? = null
|
||||
|
||||
private val unitActionsTable = Table()
|
||||
|
||||
init {
|
||||
|
||||
pad(20f)
|
||||
//background = tileTableBackground
|
||||
|
||||
add(Table().apply {
|
||||
add(prevIdleUnitButton)
|
||||
@ -30,13 +27,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
}).colspan(2)
|
||||
row()
|
||||
add(unitDescriptionLabel)
|
||||
add(unitActionsTable)
|
||||
}
|
||||
|
||||
fun update() {
|
||||
prevIdleUnitButton.update()
|
||||
nextIdleUnitButton.update()
|
||||
unitActionsTable.clear()
|
||||
|
||||
if(selectedUnit!=null)
|
||||
{
|
||||
try{ selectedUnit!!.getTile()}
|
||||
@ -61,18 +57,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
|
||||
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 {
|
||||
unitNameLabel.setText("")
|
||||
unitDescriptionLabel.setText("")
|
||||
}
|
||||
|
||||
unitActionsTable.pack()
|
||||
pack()
|
||||
|
||||
}
|
||||
|
||||
fun tileSelected(selectedTile: TileInfo) {
|
||||
@ -95,3 +87,4 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user