Organized Unit Table UI

This commit is contained in:
Yair Morgenstern 2018-11-23 14:36:22 +02:00
parent c71f320731
commit 5b66f8f0f7
8 changed files with 124 additions and 67 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

View File

@ -697,6 +697,13 @@ ImprovementIcons/Trading post
orig: 100, 100 orig: 100, 100
offset: 0, 0 offset: 0, 0
index: -1 index: -1
OtherIcons/BackArrow
rotate: false
xy: 1734, 1215
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
OtherIcons/Banner OtherIcons/Banner
rotate: false rotate: false
xy: 1297, 1727 xy: 1297, 1727
@ -811,273 +818,273 @@ PolicyIcons/Aristocracy
index: -1 index: -1
PolicyIcons/Citizenship PolicyIcons/Citizenship
rotate: false rotate: false
xy: 1734, 1215 xy: 1734, 1163
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Civil Society PolicyIcons/Civil Society
rotate: false rotate: false
xy: 1734, 1163 xy: 1734, 1111
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Collective Rule PolicyIcons/Collective Rule
rotate: false rotate: false
xy: 1734, 1111 xy: 1734, 1059
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Constitution PolicyIcons/Constitution
rotate: false rotate: false
xy: 1734, 1059 xy: 1734, 1007
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Democracy PolicyIcons/Democracy
rotate: false rotate: false
xy: 1734, 1007 xy: 1734, 955
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Discipline PolicyIcons/Discipline
rotate: false rotate: false
xy: 1734, 955 xy: 1734, 903
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Entrepreneurship PolicyIcons/Entrepreneurship
rotate: false rotate: false
xy: 1734, 903 xy: 1734, 851
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Facism PolicyIcons/Facism
rotate: false rotate: false
xy: 1734, 851 xy: 1734, 799
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Free Religion PolicyIcons/Free Religion
rotate: false rotate: false
xy: 1734, 799 xy: 1734, 747
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Free Speech PolicyIcons/Free Speech
rotate: false rotate: false
xy: 1734, 747 xy: 1734, 695
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Free Thought PolicyIcons/Free Thought
rotate: false rotate: false
xy: 1734, 695 xy: 1734, 643
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Humanism PolicyIcons/Humanism
rotate: false rotate: false
xy: 1734, 643 xy: 1734, 591
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Landed Elite PolicyIcons/Landed Elite
rotate: false rotate: false
xy: 1734, 591 xy: 1734, 539
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Legalism PolicyIcons/Legalism
rotate: false rotate: false
xy: 1734, 539 xy: 1734, 487
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Mandate Of Heaven PolicyIcons/Mandate Of Heaven
rotate: false rotate: false
xy: 1734, 487 xy: 1734, 435
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Mercantilism PolicyIcons/Mercantilism
rotate: false rotate: false
xy: 1734, 435 xy: 1734, 383
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Meritocracy PolicyIcons/Meritocracy
rotate: false rotate: false
xy: 1734, 383 xy: 1734, 331
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Militarism PolicyIcons/Militarism
rotate: false rotate: false
xy: 1734, 331 xy: 1892, 1237
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Military Caste PolicyIcons/Military Caste
rotate: false rotate: false
xy: 1892, 1237 xy: 1944, 1237
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Military Tradition PolicyIcons/Military Tradition
rotate: false rotate: false
xy: 1944, 1237 xy: 1786, 1187
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Monarchy PolicyIcons/Monarchy
rotate: false rotate: false
xy: 1786, 1187 xy: 1786, 1135
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Oligarchy PolicyIcons/Oligarchy
rotate: false rotate: false
xy: 1786, 1135 xy: 1838, 1187
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Organized Religion PolicyIcons/Organized Religion
rotate: false rotate: false
xy: 1838, 1187 xy: 1786, 1083
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Patronage PolicyIcons/Patronage
rotate: false rotate: false
xy: 1786, 1083 xy: 1838, 1135
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Police State PolicyIcons/Police State
rotate: false rotate: false
xy: 1838, 1135 xy: 1786, 1031
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Populism PolicyIcons/Populism
rotate: false rotate: false
xy: 1786, 1031 xy: 1838, 1083
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Professional Army PolicyIcons/Professional Army
rotate: false rotate: false
xy: 1838, 1083 xy: 1786, 979
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Protectionism PolicyIcons/Protectionism
rotate: false rotate: false
xy: 1786, 979 xy: 1838, 1031
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Reformation PolicyIcons/Reformation
rotate: false rotate: false
xy: 1838, 1031 xy: 1786, 927
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Representation PolicyIcons/Representation
rotate: false rotate: false
xy: 1786, 927 xy: 1838, 979
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Republic PolicyIcons/Republic
rotate: false rotate: false
xy: 1838, 979 xy: 1786, 875
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Scientific Revolution PolicyIcons/Scientific Revolution
rotate: false rotate: false
xy: 1786, 875 xy: 1838, 927
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Secularism PolicyIcons/Secularism
rotate: false rotate: false
xy: 1838, 927 xy: 1786, 823
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Sovereignty PolicyIcons/Sovereignty
rotate: false rotate: false
xy: 1786, 823 xy: 1838, 875
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Theocracy PolicyIcons/Theocracy
rotate: false rotate: false
xy: 1838, 875 xy: 1786, 771
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Total War PolicyIcons/Total War
rotate: false rotate: false
xy: 1786, 771 xy: 1838, 823
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Trade Unions PolicyIcons/Trade Unions
rotate: false rotate: false
xy: 1838, 823 xy: 1786, 719
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Universal Suffrage PolicyIcons/Universal Suffrage
rotate: false rotate: false
xy: 1786, 719 xy: 1838, 771
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
PolicyIcons/Warrior Code PolicyIcons/Warrior Code
rotate: false rotate: false
xy: 1838, 771 xy: 1786, 667
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -2281,14 +2288,14 @@ UnitPromotionIcons/Coastal_Raider_I_(Civ5)
index: -1 index: -1
UnitPromotionIcons/Cover_II_(Civ5) UnitPromotionIcons/Cover_II_(Civ5)
rotate: false rotate: false
xy: 1786, 697 xy: 1838, 749
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0
index: -1 index: -1
UnitPromotionIcons/Cover_I_(Civ5) UnitPromotionIcons/Cover_I_(Civ5)
rotate: false rotate: false
xy: 1838, 749 xy: 1786, 645
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0
@ -2414,28 +2421,28 @@ UnitPromotionIcons/Shock_I_(Civ5)
index: -1 index: -1
UnitPromotionIcons/Siege_(Civ5) UnitPromotionIcons/Siege_(Civ5)
rotate: false rotate: false
xy: 1786, 675 xy: 1838, 727
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0
index: -1 index: -1
UnitPromotionIcons/Targeting_III_(Civ5) UnitPromotionIcons/Targeting_III_(Civ5)
rotate: false rotate: false
xy: 1808, 697 xy: 1860, 749
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0
index: -1 index: -1
UnitPromotionIcons/Targeting_II_(Civ5) UnitPromotionIcons/Targeting_II_(Civ5)
rotate: false rotate: false
xy: 1838, 727 xy: 1786, 623
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0
index: -1 index: -1
UnitPromotionIcons/Targeting_I_(Civ5) UnitPromotionIcons/Targeting_I_(Civ5)
rotate: false rotate: false
xy: 1860, 749 xy: 1808, 645
size: 20, 20 size: 20, 20
orig: 20, 20 orig: 20, 20
offset: 0, 0 offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 KiB

After

Width:  |  Height:  |  Size: 798 KiB

View File

@ -94,6 +94,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
table.defaults().pad(10f) table.defaults().pad(10f)
table.background = ImageGetter.getBackground(civ.getNation().getColor()) table.background = ImageGetter.getBackground(civ.getNation().getColor())
table.add(Label(civ.civName.tr(),skin).setFontColor(civ.getNation().getSecondaryColor())).row() table.add(Label(civ.civName.tr(),skin).setFontColor(civ.getNation().getSecondaryColor())).row()
table.addSeparator()
for(offer in offersList){ for(offer in offersList){
var offerText = offer.amount.toString()+" "+offer.name.tr() var offerText = offer.amount.toString()+" "+offer.name.tr()
if(offer.duration>0)offerText += " ("+offer.duration+" {turns})".tr() if(offer.duration>0)offerText += " ("+offer.duration+" {turns})".tr()

View File

@ -42,6 +42,7 @@ class DiplomacyScreen():CameraStageBaseScreen(){
val peaceWarStatus = civDiplomacy.diplomaticStatus.toString() val peaceWarStatus = civDiplomacy.diplomaticStatus.toString()
civTable.add(Label(civ.civName.tr() + " ({$peaceWarStatus})".tr(), skin) civTable.add(Label(civ.civName.tr() + " ({$peaceWarStatus})".tr(), skin)
.apply { setFontSize(22); setFontColor(civ.getNation().getSecondaryColor()) }).row() .apply { setFontSize(22); setFontColor(civ.getNation().getSecondaryColor()) }).row()
civTable.addSeparator()
val tradeButton = TextButton("Trade".tr(), skin) val tradeButton = TextButton("Trade".tr(), skin)
tradeButton.onClick { tradeButton.onClick {

View File

@ -63,7 +63,10 @@ open class CameraStageBaseScreen : Screen {
var skin = Skin(Gdx.files.internal("skin/flat-earth-ui.json")) var skin = Skin(Gdx.files.internal("skin/flat-earth-ui.json"))
.apply { .apply {
get<TextButton.TextButtonStyle>(TextButton.TextButtonStyle::class.java).font = getFont(20) get<TextButton.TextButtonStyle>(TextButton.TextButtonStyle::class.java).font = getFont(20)
get<Label.LabelStyle>(Label.LabelStyle::class.java).font = getFont(18) get<Label.LabelStyle>(Label.LabelStyle::class.java).apply {
font = getFont(18)
fontColor= Color.WHITE
}
get<TextField.TextFieldStyle>(TextField.TextFieldStyle::class.java).font = getFont(18) get<TextField.TextFieldStyle>(TextField.TextFieldStyle::class.java).font = getFont(18)
get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).font = getFont(20) get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).font = getFont(20)
get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).listStyle.font = getFont(20) get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).listStyle.font = getFont(20)
@ -193,3 +196,9 @@ fun Actor.onClick(function: () -> Unit) {
fun Image.surroundWithCircle(size:Float): IconCircleGroup { fun Image.surroundWithCircle(size:Float): IconCircleGroup {
return IconCircleGroup(size,this) return IconCircleGroup(size,this)
} }
fun Table.addSeparator(): Image {
val image = ImageGetter.getWhiteDot()
add(image).colspan(columns).fill().row()
return image
}

View File

@ -1,18 +1,32 @@
package com.unciv.ui.worldscreen.unit package com.unciv.ui.worldscreen.unit
import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
import com.unciv.ui.worldscreen.TileMapHolder import com.unciv.ui.worldscreen.TileMapHolder
class IdleUnitButton internal constructor(internal val unitTable: UnitTable, class IdleUnitButton (internal val unitTable: UnitTable,
val tileMapHolder: TileMapHolder, val previous:Boolean) val tileMapHolder: TileMapHolder, val previous:Boolean)
: TextButton(if(previous)"<" else ">", CameraStageBaseScreen.skin) { : Table() {
val image = ImageGetter.getImage("OtherIcons/BackArrow")
fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values fun getTilesWithIdleUnits() = tileMapHolder.tileMap.values
.filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.civInfo.civName } .filter { it.hasIdleUnit() && it.getUnits().first().owner == unitTable.worldScreen.civInfo.civName }
init { init {
val imageSize = 25f
if(!previous){
image.setSize(imageSize,imageSize)
image.setOrigin(Align.center)
image.rotateBy(180f)
}
add(image).size(imageSize).pad(10f,20f,10f,20f)
enable()
onClick { onClick {
val tilesWithIdleUnits = getTilesWithIdleUnits() val tilesWithIdleUnits = getTilesWithIdleUnits()
@ -30,5 +44,15 @@ class IdleUnitButton internal constructor(internal val unitTable: UnitTable,
unitTable.worldScreen.update() unitTable.worldScreen.update()
} }
} }
fun enable(){
image.color= Color.WHITE
touchable=Touchable.enabled
}
fun disable(){
image.color= Color.GRAY
touchable=Touchable.disabled
}
} }

View File

@ -1,5 +1,6 @@
package com.unciv.ui.worldscreen.unit package com.unciv.ui.worldscreen.unit
import com.badlogic.gdx.scenes.scene2d.ui.Image
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.unciv.logic.map.MapUnit import com.unciv.logic.map.MapUnit
@ -14,13 +15,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
private val unitIconHolder=Table() private val unitIconHolder=Table()
private val unitNameLabel = Label("",CameraStageBaseScreen.skin) private val unitNameLabel = Label("",CameraStageBaseScreen.skin)
private val promotionsTable = Table() private val promotionsTable = Table()
private val unitDescriptionLabel = Label("",CameraStageBaseScreen.skin) private val unitDescriptionTable = Table(CameraStageBaseScreen.skin)
var selectedUnit : MapUnit? = null var selectedUnit : MapUnit? = null
var currentlyExecutingAction : String? = null var currentlyExecutingAction : String? = null
// This is so that not on every update(), we will update the unit table. // This is so that not on every update(), we will update the unit table.
// Most of the time it's the same unit with the same stats so why waste precious time? // Most of the time it's the same unit with the same stats so why waste precious time?
var selectedUnitHasChanged = false var selectedUnitHasChanged = false
val separator: Image
init { init {
pad(5f) pad(5f)
@ -31,8 +33,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
add(unitNameLabel).pad(5f) add(unitNameLabel).pad(5f)
add(nextIdleUnitButton) add(nextIdleUnitButton)
}).colspan(2).row() }).colspan(2).row()
add(promotionsTable).row() separator= addSeparator()
add(unitDescriptionLabel) add(promotionsTable).colspan(2).row()
add(unitDescriptionTable)
} }
fun update() { fun update() {
@ -58,32 +61,45 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
} }
if(selectedUnit!=null) { // set texts - this is valid even when it's the same unit, because movement points and health change if(selectedUnit!=null) { // set texts - this is valid even when it's the same unit, because movement points and health change
separator.isVisible=true
val unit = selectedUnit!! val unit = selectedUnit!!
var nameLabelText = unit.name.tr() var nameLabelText = unit.name.tr()
if(unit.health<100) nameLabelText+=" ("+unit.health+")" if(unit.health<100) nameLabelText+=" ("+unit.health+")"
unitNameLabel.setText(nameLabelText) unitNameLabel.setText(nameLabelText)
var unitLabelText = "Movement".tr()+": " + unit.getMovementString() unitDescriptionTable.clear()
if (!unit.type.isCivilian()) unitDescriptionTable.defaults().pad(2f).padRight(5f)
unitLabelText += "\n"+"Strength".tr()+": " + unit.baseUnit().strength unitDescriptionTable.add("Movement")
unitDescriptionTable.add(unit.getMovementString()).row()
if (unit.baseUnit().rangedStrength!=0) if (!unit.type.isCivilian()) {
unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.baseUnit().rangedStrength unitDescriptionTable.add("Strength")
unitDescriptionTable.add(unit.baseUnit().strength.toString()).row()
}
if (!unit.type.isCivilian()) if (unit.baseUnit().rangedStrength!=0) {
unitLabelText += "\n"+"XP".tr()+": "+unit.promotions.XP+"/"+unit.promotions.xpForNextPromotion() unitDescriptionTable.add("Ranged strength")
unitDescriptionTable.add(unit.baseUnit().rangedStrength.toString()).row()
}
if(unit.isFortified() && unit.getFortificationTurns()>0) if (!unit.type.isCivilian()) {
unitLabelText+="\n+"+unit.getFortificationTurns()*20+"% fortification" unitDescriptionTable.add("XP")
unitDescriptionTable.add(unit.promotions.XP.toString()+"/"+unit.promotions.xpForNextPromotion()).row()
}
unitDescriptionLabel.setText(unitLabelText) if(unit.isFortified() && unit.getFortificationTurns()>0) {
unitDescriptionTable.add("Fortification")
unitDescriptionTable.add(""+unit.getFortificationTurns() * 20 + "%")
}
unitDescriptionTable.pack()
if(unit.promotions.promotions.size != promotionsTable.children.size) // The unit has been promoted! Reload promotions! if(unit.promotions.promotions.size != promotionsTable.children.size) // The unit has been promoted! Reload promotions!
selectedUnitHasChanged = true selectedUnitHasChanged = true
} }
else { else {
separator.isVisible=false
unitNameLabel.setText("") unitNameLabel.setText("")
unitDescriptionLabel.setText("") unitDescriptionTable.clear()
unitIconHolder.clear() unitIconHolder.clear()
} }
@ -91,15 +107,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
unitIconHolder.clear() unitIconHolder.clear()
promotionsTable.clear() promotionsTable.clear()
unitDescriptionLabel.clearListeners() unitDescriptionTable.clearListeners()
if(selectedUnit!=null) { if(selectedUnit!=null) {
unitIconHolder.add(TileGroup(TileInfo()).getUnitImage(selectedUnit!!,30f)).pad(5f) unitIconHolder.add(TileGroup(TileInfo()).getUnitImage(selectedUnit!!,30f)).pad(5f)
for(promotion in selectedUnit!!.promotions.promotions) for(promotion in selectedUnit!!.promotions.promotions)
promotionsTable.add(ImageGetter.getPromotionIcon(promotion)).size(20f) promotionsTable.add(ImageGetter.getPromotionIcon(promotion)).size(20f)
unitDescriptionLabel.onClick { worldScreen.tileMapHolder.setCenterPosition(selectedUnit!!.getTile().position) } unitDescriptionTable.onClick { worldScreen.tileMapHolder.setCenterPosition(selectedUnit!!.getTile().position) }
} }
pack() pack()