mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Added unit icons to battle table
This commit is contained in:
parent
254d415968
commit
5577022bd7
@ -18,9 +18,9 @@ com.badlogic.gdx.graphics.Color: {
|
|||||||
a: 1
|
a: 1
|
||||||
}
|
}
|
||||||
color: {
|
color: {
|
||||||
r: 0.3372549
|
r: 0.2
|
||||||
g: 0.7
|
g: 0.3
|
||||||
b: 0.44705883
|
b: 0.5
|
||||||
a: 1
|
a: 1
|
||||||
}
|
}
|
||||||
gray: {
|
gray: {
|
||||||
|
@ -147,6 +147,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
|
|
||||||
greatPeopleTable.defaults().pad(5f)
|
greatPeopleTable.defaults().pad(5f)
|
||||||
greatPeopleTable.add(Label("Great person points".tr(), skin).setFontSize(24)).colspan(3).row()
|
greatPeopleTable.add(Label("Great person points".tr(), skin).setFontSize(24)).colspan(3).row()
|
||||||
|
greatPeopleTable.addSeparator()
|
||||||
greatPeopleTable.add()
|
greatPeopleTable.add()
|
||||||
greatPeopleTable.add("Current points")
|
greatPeopleTable.add("Current points")
|
||||||
greatPeopleTable.add("Points per turn").row()
|
greatPeopleTable.add("Points per turn").row()
|
||||||
@ -239,6 +240,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
table.add("Movement".tr())
|
table.add("Movement".tr())
|
||||||
table.add("Closest city".tr())
|
table.add("Closest city".tr())
|
||||||
table.row()
|
table.row()
|
||||||
|
table.addSeparator()
|
||||||
|
|
||||||
for(unit in civInfo.getCivUnits()){
|
for(unit in civInfo.getCivUnits()){
|
||||||
val baseUnit = unit.baseUnit()
|
val baseUnit = unit.baseUnit()
|
||||||
table.add(unit.name.tr())
|
table.add(unit.name.tr())
|
||||||
|
@ -321,7 +321,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (unit != null && isViewable) { // Tile is visible
|
if (unit != null && isViewable) { // Tile is visible
|
||||||
newImage = getUnitImage(unit, 25f)
|
newImage = ImageGetter.getUnitImage(unit, 25f)
|
||||||
addActor(newImage)
|
addActor(newImage)
|
||||||
newImage.center(this)
|
newImage.center(this)
|
||||||
newImage.y += yFromCenter
|
newImage.y += yFromCenter
|
||||||
@ -331,37 +331,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
return newImage
|
return newImage
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBackgroundImageForUnit(unit: MapUnit):Image{
|
|
||||||
return when {
|
|
||||||
unit.isEmbarked() -> ImageGetter.getImage("OtherIcons/Banner")
|
|
||||||
unit.isFortified() -> ImageGetter.getImage("OtherIcons/Shield.png")
|
|
||||||
else -> ImageGetter.getImage("OtherIcons/Circle.png")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getUnitImage(unit: MapUnit, size: Float): Group {
|
|
||||||
val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.getNation().getSecondaryColor())
|
|
||||||
.apply { setSize(size*0.75f, size*0.75f) }
|
|
||||||
|
|
||||||
val background = getBackgroundImageForUnit(unit)
|
|
||||||
background.apply {
|
|
||||||
this.color = unit.civInfo.getNation().getColor()
|
|
||||||
setSize(size, size)
|
|
||||||
}
|
|
||||||
val group = Group().apply {
|
|
||||||
setSize(size, size)
|
|
||||||
addActor(background)
|
|
||||||
}
|
|
||||||
unitBaseImage.center(group)
|
|
||||||
group.addActor(unitBaseImage)
|
|
||||||
|
|
||||||
|
|
||||||
if (unit.health < 100) { // add health bar
|
|
||||||
group.addActor(ImageGetter.getHealthBar(unit.health.toFloat(),100f,size))
|
|
||||||
}
|
|
||||||
|
|
||||||
return group
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun showCircle(color: Color) {
|
fun showCircle(color: Color) {
|
||||||
|
@ -5,6 +5,7 @@ import com.unciv.logic.city.CityInfo
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.center
|
import com.unciv.ui.utils.center
|
||||||
|
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
var cityButton: CityButton? = null
|
var cityButton: CityButton? = null
|
||||||
|
|
||||||
fun addWhiteHaloAroundUnit(unit: MapUnit) {
|
fun addWhiteHaloAroundUnit(unit: MapUnit) {
|
||||||
val whiteHalo = getBackgroundImageForUnit(unit)
|
val whiteHalo = ImageGetter.getBackgroundImageForUnit(unit)
|
||||||
whiteHalo.setSize(30f,30f)
|
whiteHalo.setSize(30f,30f)
|
||||||
val unitImage = if(unit.type.isCivilian()) civilianUnitImage
|
val unitImage = if(unit.type.isCivilian()) civilianUnitImage
|
||||||
else militaryUnitImage
|
else militaryUnitImage
|
||||||
|
@ -197,8 +197,10 @@ fun Image.surroundWithCircle(size:Float): IconCircleGroup {
|
|||||||
return IconCircleGroup(size,this)
|
return IconCircleGroup(size,this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Table.addSeparator(): Image {
|
fun Table.addSeparator(): Cell<Image> {
|
||||||
|
row()
|
||||||
val image = ImageGetter.getWhiteDot()
|
val image = ImageGetter.getWhiteDot()
|
||||||
add(image).colspan(columns).fill().row()
|
val cell = add(image).colspan(columns).fill()
|
||||||
return image
|
row()
|
||||||
|
return cell
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.tile.ResourceType
|
import com.unciv.models.gamebasics.tile.ResourceType
|
||||||
|
|
||||||
@ -157,4 +158,38 @@ object ImageGetter {
|
|||||||
return healthBar
|
return healthBar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getUnitImage(unit: MapUnit, size: Float): Group {
|
||||||
|
val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.getNation().getSecondaryColor())
|
||||||
|
.apply { setSize(size*0.75f, size*0.75f) }
|
||||||
|
|
||||||
|
val background = getBackgroundImageForUnit(unit)
|
||||||
|
background.apply {
|
||||||
|
this.color = unit.civInfo.getNation().getColor()
|
||||||
|
setSize(size, size)
|
||||||
|
}
|
||||||
|
val group = Group().apply {
|
||||||
|
setSize(size, size)
|
||||||
|
addActor(background)
|
||||||
|
}
|
||||||
|
unitBaseImage.center(group)
|
||||||
|
group.addActor(unitBaseImage)
|
||||||
|
|
||||||
|
|
||||||
|
if (unit.health < 100) { // add health bar
|
||||||
|
group.addActor(ImageGetter.getHealthBar(unit.health.toFloat(),100f,size))
|
||||||
|
}
|
||||||
|
|
||||||
|
return group
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBackgroundImageForUnit(unit: MapUnit):Image{
|
||||||
|
return when {
|
||||||
|
unit.isEmbarked() -> ImageGetter.getImage("OtherIcons/Banner")
|
||||||
|
unit.isFortified() -> ImageGetter.getImage("OtherIcons/Shield.png")
|
||||||
|
else -> ImageGetter.getImage("OtherIcons/Circle.png")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
import com.unciv.ui.tilegroups.TileGroup
|
|
||||||
import com.unciv.ui.tilegroups.WorldTileGroup
|
import com.unciv.ui.tilegroups.WorldTileGroup
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
moveHereButton.addActor(numberCircle)
|
moveHereButton.addActor(numberCircle)
|
||||||
moveHereButton.addActor(Label(turnsToGetThere.toString(), CameraStageBaseScreen.skin).apply { center(numberCircle); setFontColor(Color.WHITE) })
|
moveHereButton.addActor(Label(turnsToGetThere.toString(), CameraStageBaseScreen.skin).apply { center(numberCircle); setFontColor(Color.WHITE) })
|
||||||
|
|
||||||
val unitIcon = TileGroup(TileInfo()).getUnitImage(selectedUnit, size / 2)
|
val unitIcon = ImageGetter.getUnitImage(selectedUnit, size / 2)
|
||||||
unitIcon.y = size - unitIcon.height
|
unitIcon.y = size - unitIcon.height
|
||||||
moveHereButton.addActor(unitIcon)
|
moveHereButton.addActor(unitIcon)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
topBar.y - nextTurnButton.height - 10f)
|
topBar.y - nextTurnButton.height - 10f)
|
||||||
notificationsScroll = NotificationsScroll(this)
|
notificationsScroll = NotificationsScroll(this)
|
||||||
notificationsScroll.width = stage.width/3
|
notificationsScroll.width = stage.width/3
|
||||||
|
|
||||||
val externalMinimapWrapper = Table()
|
val externalMinimapWrapper = Table()
|
||||||
val internalMinimapWrapper = Table()
|
val internalMinimapWrapper = Table()
|
||||||
internalMinimapWrapper.add(minimap).size(stage.width/5,stage.height/5)
|
internalMinimapWrapper.add(minimap).size(stage.width/5,stage.height/5)
|
||||||
|
@ -53,20 +53,28 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
|
|
||||||
fun simulateBattle(attacker: MapUnitCombatant, defender: ICombatant){
|
fun simulateBattle(attacker: MapUnitCombatant, defender: ICombatant){
|
||||||
clear()
|
clear()
|
||||||
row().pad(5f)
|
defaults().pad(5f)
|
||||||
|
|
||||||
|
val attackerNameWrapper = Table()
|
||||||
val attackerLabel = Label(attacker.getName(), skin)
|
val attackerLabel = Label(attacker.getName(), skin)
|
||||||
.setFontColor(attacker.getCivilization().getNation().getColor())
|
// .setFontColor(attacker.getCivilization().getNation().getColor())
|
||||||
add(attackerLabel)
|
attackerNameWrapper.add(ImageGetter.getUnitImage(attacker.unit,25f)).padRight(5f)
|
||||||
|
attackerNameWrapper.add(attackerLabel)
|
||||||
|
add(attackerNameWrapper)
|
||||||
|
|
||||||
|
val defenderNameWrapper = Table()
|
||||||
val defenderLabel = Label(defender.getName(), skin)
|
val defenderLabel = Label(defender.getName(), skin)
|
||||||
.setFontColor(defender.getCivilization().getNation().getColor())
|
// .setFontColor(defender.getCivilization().getNation().getColor())
|
||||||
add(defenderLabel)
|
if(defender is MapUnitCombatant)
|
||||||
|
defenderNameWrapper.add(ImageGetter.getUnitImage(defender.unit,25f)).padRight(5f)
|
||||||
|
|
||||||
row().pad(5f)
|
defenderNameWrapper.add(defenderLabel)
|
||||||
|
add(defenderNameWrapper).row()
|
||||||
|
|
||||||
|
addSeparator().pad(0f)
|
||||||
|
|
||||||
add("{Strength}: ".tr()+attacker.getAttackingStrength(defender))
|
add("{Strength}: ".tr()+attacker.getAttackingStrength(defender))
|
||||||
add("{Strength}: ".tr()+defender.getDefendingStrength(attacker))
|
add("{Strength}: ".tr()+defender.getDefendingStrength(attacker)).row()
|
||||||
row().pad(5f)
|
|
||||||
|
|
||||||
val attackerModifiers = BattleDamage().getAttackModifiers(attacker,defender) .map { it.key+": "+(if(it.value>0)"+" else "")+(it.value*100).toInt()+"%" }
|
val attackerModifiers = BattleDamage().getAttackModifiers(attacker,defender) .map { it.key+": "+(if(it.value>0)"+" else "")+(it.value*100).toInt()+"%" }
|
||||||
val defenderModifiers = if (defender is MapUnitCombatant)
|
val defenderModifiers = if (defender is MapUnitCombatant)
|
||||||
|
@ -5,7 +5,6 @@ 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
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.tilegroups.TileGroup
|
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
add(unitNameLabel).pad(5f)
|
add(unitNameLabel).pad(5f)
|
||||||
add(nextIdleUnitButton)
|
add(nextIdleUnitButton)
|
||||||
}).colspan(2).row()
|
}).colspan(2).row()
|
||||||
separator= addSeparator()
|
separator= addSeparator().actor!!
|
||||||
add(promotionsTable).colspan(2).row()
|
add(promotionsTable).colspan(2).row()
|
||||||
add(unitDescriptionTable)
|
add(unitDescriptionTable)
|
||||||
}
|
}
|
||||||
@ -110,7 +109,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
unitDescriptionTable.clearListeners()
|
unitDescriptionTable.clearListeners()
|
||||||
|
|
||||||
if(selectedUnit!=null) {
|
if(selectedUnit!=null) {
|
||||||
unitIconHolder.add(TileGroup(TileInfo()).getUnitImage(selectedUnit!!,30f)).pad(5f)
|
unitIconHolder.add(ImageGetter.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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user