Unit Overview: Improving a tile is also "what the unit is doing" (#9482)

* Unit Overview: Improving a tile is also "what the unit is doing"

* Unit Overview automated worker actions
This commit is contained in:
SomeTroglodyte
2023-05-31 13:50:42 +02:00
committed by GitHub
parent 9302036311
commit 2c1d413b6c
6 changed files with 95 additions and 77 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -39,100 +39,107 @@ CityStateIcons/Religious
orig: 100, 100 orig: 100, 100
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Culture EmojiIcons/Automate
rotate: false rotate: false
xy: 436, 316 xy: 436, 432
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Death EmojiIcons/Culture
rotate: false rotate: false
xy: 436, 258 xy: 436, 258
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Faith EmojiIcons/Death
rotate: false rotate: false
xy: 436, 200 xy: 436, 200
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Food EmojiIcons/Faith
rotate: false rotate: false
xy: 436, 142 xy: 436, 142
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Gold EmojiIcons/Food
rotate: false rotate: false
xy: 436, 26 xy: 436, 84
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Great Artist EmojiIcons/Gold
rotate: false rotate: false
xy: 494, 432 xy: 494, 432
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Great Engineer EmojiIcons/Great Artist
rotate: false rotate: false
xy: 494, 374 xy: 494, 374
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Great General EmojiIcons/Great Engineer
rotate: false rotate: false
xy: 494, 316 xy: 494, 316
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Great Merchant EmojiIcons/Great General
rotate: false rotate: false
xy: 494, 258 xy: 494, 258
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Great Scientist EmojiIcons/Great Merchant
rotate: false rotate: false
xy: 494, 200 xy: 494, 200
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Happiness EmojiIcons/Great Scientist
rotate: false rotate: false
xy: 494, 142 xy: 494, 142
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Happiness
rotate: false
xy: 494, 84
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
EmojiIcons/Production EmojiIcons/Production
rotate: false rotate: false
xy: 552, 273 xy: 552, 215
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Science EmojiIcons/Science
rotate: false rotate: false
xy: 552, 99 xy: 552, 41
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
EmojiIcons/Turn EmojiIcons/Turn
rotate: false rotate: false
xy: 544, 1087 xy: 544, 1029
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -503,7 +510,7 @@ StatIcons/Movement
index: -1 index: -1
OtherIcons/BackArrow OtherIcons/BackArrow
rotate: false rotate: false
xy: 436, 432 xy: 436, 374
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -580,7 +587,7 @@ OtherIcons/Cities
index: -1 index: -1
OtherIcons/CityState OtherIcons/CityState
rotate: false rotate: false
xy: 436, 374 xy: 436, 316
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -636,7 +643,7 @@ OtherIcons/Fire
index: -1 index: -1
OtherIcons/ForwardArrow OtherIcons/ForwardArrow
rotate: false rotate: false
xy: 436, 84 xy: 436, 26
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -657,7 +664,7 @@ OtherIcons/HexagonOutline
index: -1 index: -1
OtherIcons/Improvements OtherIcons/Improvements
rotate: false rotate: false
xy: 494, 84 xy: 494, 26
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -671,7 +678,7 @@ OtherIcons/Keyboard
index: -1 index: -1
OtherIcons/Link OtherIcons/Link
rotate: false rotate: false
xy: 527, 505 xy: 552, 447
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -706,7 +713,7 @@ NotificationIcons/Working
index: -1 index: -1
OtherIcons/LockSmall OtherIcons/LockSmall
rotate: false rotate: false
xy: 552, 447 xy: 552, 389
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -748,7 +755,7 @@ OtherIcons/NationSwap
index: -1 index: -1
OtherIcons/Nations OtherIcons/Nations
rotate: false rotate: false
xy: 552, 389 xy: 552, 331
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -776,7 +783,7 @@ OtherIcons/Options
index: -1 index: -1
OtherIcons/Pause OtherIcons/Pause
rotate: false rotate: false
xy: 552, 331 xy: 552, 273
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -1287,7 +1294,7 @@ StatIcons/Happiness
index: -1 index: -1
StatIcons/InterceptRange StatIcons/InterceptRange
rotate: false rotate: false
xy: 494, 26 xy: 527, 505
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -1315,14 +1322,14 @@ TileIcons/Worked
index: -1 index: -1
StatIcons/Range StatIcons/Range
rotate: false rotate: false
xy: 552, 215 xy: 552, 157
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
index: -1 index: -1
StatIcons/RangedStrength StatIcons/RangedStrength
rotate: false rotate: false
xy: 552, 157 xy: 552, 99
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0
@ -1350,7 +1357,7 @@ StatIcons/Specialist
index: -1 index: -1
StatIcons/Strength StatIcons/Strength
rotate: false rotate: false
xy: 552, 41 xy: 544, 1087
size: 50, 50 size: 50, 50
orig: 50, 50 orig: 50, 50
offset: 0, 0 offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 KiB

After

Width:  |  Height:  |  Size: 519 KiB

View File

@ -48,7 +48,7 @@ class FontFamilyData(
val filePath: String? = null val filePath: String? = null
) { ) {
// For serialization @Suppress("unused") // For serialization
constructor() : this(default.localName, default.invariantName) constructor() : this(default.localName, default.invariantName)
// Implement kotlin equality contract such that _only_ the invariantName field is compared. // Implement kotlin equality contract such that _only_ the invariantName field is compared.
@ -138,29 +138,7 @@ class NativeBitmapFontData(
private fun getPixmapFromChar(ch: Char): Pixmap { private fun getPixmapFromChar(ch: Char): Pixmap {
// Images must be 50*50px so they're rendered at the same height as the text - see Fonts.ORIGINAL_FONT_SIZE // Images must be 50*50px so they're rendered at the same height as the text - see Fonts.ORIGINAL_FONT_SIZE
return when (ch) { return when (ch) {
Fonts.strength -> getPixmap("StatIcons/Strength") in Fonts.allSymbols -> getPixmap(Fonts.allSymbols[ch]!!)
Fonts.rangedStrength -> getPixmap("StatIcons/RangedStrength")
Fonts.range -> getPixmap("StatIcons/Range")
Fonts.movement -> getPixmap("StatIcons/Movement")
Fonts.turn -> getPixmap("EmojiIcons/Turn")
Fonts.production -> getPixmap("EmojiIcons/Production")
Fonts.gold -> getPixmap("EmojiIcons/Gold")
Fonts.food -> getPixmap("EmojiIcons/Food")
Fonts.science -> getPixmap("EmojiIcons/Science")
Fonts.culture -> getPixmap("EmojiIcons/Culture")
Fonts.faith -> getPixmap("EmojiIcons/Faith")
Fonts.happiness -> getPixmap("EmojiIcons/Happiness")
Fonts.greatArtist -> getPixmap("EmojiIcons/Great Artist")
Fonts.greatEngineer -> getPixmap("EmojiIcons/Great Engineer")
Fonts.greatGeneral -> getPixmap("EmojiIcons/Great General")
Fonts.greatMerchant -> getPixmap("EmojiIcons/Great Merchant")
Fonts.greatScientist -> getPixmap("EmojiIcons/Great Scientist")
Fonts.death -> getPixmap("EmojiIcons/Death")
MayaCalendar.tun -> getPixmap(MayaCalendar.tunIcon)
MayaCalendar.katun -> getPixmap(MayaCalendar.katunIcon)
MayaCalendar.baktun -> getPixmap(MayaCalendar.baktunIcon)
in MayaCalendar.digits -> getPixmap(MayaCalendar.digitIcon(ch))
in Fonts.charToRulesetImageActor -> in Fonts.charToRulesetImageActor ->
try { try {
// This sometimes fails with a "Frame buffer couldn't be constructed: incomplete attachment" error, unclear why // This sometimes fails with a "Frame buffer couldn't be constructed: incomplete attachment" error, unclear why
@ -249,7 +227,7 @@ object Fonts {
val rulesetObjectNameToChar =HashMap<String, Char>() val rulesetObjectNameToChar =HashMap<String, Char>()
val charToRulesetImageActor = HashMap<Char, Actor>() val charToRulesetImageActor = HashMap<Char, Actor>()
// See https://en.wikipedia.org/wiki/Private_Use_Areas - char encodings 57344 63743 are not assigned // See https://en.wikipedia.org/wiki/Private_Use_Areas - char encodings 57344 63743 are not assigned
var nextUnusedCharacterNumber = 57344 private var nextUnusedCharacterNumber = 57344
fun addRulesetImages(ruleset:Ruleset) { fun addRulesetImages(ruleset:Ruleset) {
rulesetObjectNameToChar.clear() rulesetObjectNameToChar.clear()
charToRulesetImageActor.clear() charToRulesetImageActor.clear()
@ -290,8 +268,8 @@ object Fonts {
} }
} }
val frameBuffer by lazy { FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false) } private val frameBuffer by lazy { FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.width, Gdx.graphics.height, false) }
val spriteBatch by lazy { SpriteBatch() } private val spriteBatch by lazy { SpriteBatch() }
fun getPixmapFromActor(actor: Actor): Pixmap { fun getPixmapFromActor(actor: Actor): Pixmap {
@ -336,19 +314,39 @@ object Fonts {
const val culture = '♪' // U+266A 'eighth note' (🎵 U+1F3B5 'musical note') const val culture = '♪' // U+266A 'eighth note' (🎵 U+1F3B5 'musical note')
const val happiness = '⌣' // U+2323 'smile' (😀 U+1F600 'grinning face') const val happiness = '⌣' // U+2323 'smile' (😀 U+1F600 'grinning face')
const val faith = '☮' // U+262E 'peace symbol' (🕊 U+1F54A 'dove of peace') const val faith = '☮' // U+262E 'peace symbol' (🕊 U+1F54A 'dove of peace')
const val greatArtist = '♬' // U+266C 'sixteenth note' @Suppress("MemberVisibilityCanBePrivate") // offer for mods
const val greatArtist = '♬' // U+266C 'sixteenth note'
@Suppress("MemberVisibilityCanBePrivate") // offer for mods
const val greatEngineer = '⚒' // U+2692 'hammer' const val greatEngineer = '⚒' // U+2692 'hammer'
const val greatGeneral = '⛤' // U+26E4 'pentagram' @Suppress("MemberVisibilityCanBePrivate") // offer for mods
const val greatMerchant = '' // U+2696 'scale' const val greatGeneral = '' // U+26E4 'pentagram'
@Suppress("MemberVisibilityCanBePrivate") // offer for mods
const val greatMerchant = '⚖' // U+2696 'scale'
@Suppress("MemberVisibilityCanBePrivate") // offer for mods
const val greatScientist = '⚛' // U+269B 'atom' const val greatScientist = '⚛' // U+269B 'atom'
const val death = '☠' // U+2620 'skull and crossbones' const val death = '☠' // U+2620 'skull and crossbones'
const val automate = '⛏' // U+26CF 'pick'
val allSymbols = arrayOf<Char>( val allSymbols = mapOf(
turn, turn to "EmojiIcons/Turn",
strength, rangedStrength, range, movement, strength to "StatIcons/Strength",
production, gold, food, science, culture, happiness, faith, rangedStrength to "StatIcons/RangedStrength",
greatArtist, greatEngineer, greatGeneral, greatMerchant, greatScientist, range to "StatIcons/Range",
death, movement to "StatIcons/Movement",
production to "EmojiIcons/Production",
gold to "EmojiIcons/Gold",
food to "EmojiIcons/Food",
science to "EmojiIcons/Science",
culture to "EmojiIcons/Culture",
happiness to "EmojiIcons/Happiness",
faith to "EmojiIcons/Faith",
greatArtist to "EmojiIcons/Great Artist",
greatEngineer to "EmojiIcons/Great Engineer",
greatGeneral to "EmojiIcons/Great General",
greatMerchant to "EmojiIcons/Great Merchant",
greatScientist to "EmojiIcons/Great Scientist",
death to "EmojiIcons/Death",
automate to "EmojiIcons/Automate",
*MayaCalendar.allSymbols *MayaCalendar.allSymbols
) )
} }

View File

@ -13,6 +13,7 @@ import com.unciv.ui.components.extensions.addSeparator
import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.basescreen.BaseScreen
import kotlin.math.abs import kotlin.math.abs
@Suppress("MemberVisibilityCanBePrivate") // stuff only accessed through allSymbols looks cleaner with same visibility
object MayaCalendar { object MayaCalendar {
// Glyphs / icons // Glyphs / icons
private const val iconFolder = "MayaCalendar/" private const val iconFolder = "MayaCalendar/"
@ -31,12 +32,12 @@ object MayaCalendar {
fun digitIcon(ch: Char) = iconFolder + (ch.toCode() - zero.toCode()).toString() fun digitIcon(ch: Char) = iconFolder + (ch.toCode() - zero.toCode()).toString()
val allSymbols = sequence { val allSymbols = sequence {
yield(tun) yield(tun to tunIcon)
yield(katun) yield(katun to katunIcon)
yield(baktun) yield(baktun to baktunIcon)
yieldAll(digits) yieldAll(digits.map {it to digitIcon(it)})
}.iterator().run { }.iterator().run {
Array<Char>(23) { next() } Array(23) { next() }
} }
// Calculation // Calculation

View File

@ -153,7 +153,7 @@ class UnitOverviewTab(
private fun Table.updateUnitHeaderTable(): Table { private fun Table.updateUnitHeaderTable(): Table {
defaults().pad(5f) defaults().pad(5f)
add("Name".toLabel()) add("Name".toLabel())
add() add() // Column: edit-name
add("Action".toLabel()) add("Action".toLabel())
add(Fonts.strength.toString().toLabel()) add(Fonts.strength.toString().toLabel())
add(Fonts.rangedStrength.toString().toLabel()) add(Fonts.rangedStrength.toString().toLabel())
@ -206,13 +206,25 @@ class UnitOverviewTab(
add(editIcon) add(editIcon)
// Column: action // Column: action
fun getActionLabel(unit: MapUnit) = when { fun getWorkerActionText(unit: MapUnit): String? = when {
unit.action == null -> "" // See UnitTurnManager.endTurn, if..workOnImprovement or UnitGroup.getActionImage: similar logic
unit.isFortified() -> UnitActionType.Fortify.value !unit.cache.hasUniqueToBuildImprovements -> null
unit.isMoving() -> "Moving" unit.currentMovement == 0f -> null
else -> unit.action!! unit.currentTile.improvementInProgress == null -> null
!unit.canBuildImprovement(unit.getTile().getTileImprovementInProgress()!!) -> null
else -> unit.currentTile.improvementInProgress
} }
if (unit.action == null) add() else add(getActionLabel(unit).toLabel()) fun getActionText(unit: MapUnit): String? {
val workerText by lazy { getWorkerActionText(unit) }
return when {
unit.action == null -> workerText
unit.isFortified() -> UnitActionType.Fortify.value
unit.isMoving() -> "Moving"
unit.isAutomated() && workerText != null -> "[$workerText] ${Fonts.automate}"
else -> unit.action
}
}
add(getActionText(unit)?.toLabel())
// Columns: strength, ranged // Columns: strength, ranged
if (baseUnit.strength > 0) add(baseUnit.strength.toLabel()) else add() if (baseUnit.strength > 0) add(baseUnit.strength.toLabel()) else add()