Resolved #2413 - Yes, having the hotkey always be on display does look much nicer, and I think it's more user-firendly too (no more 'wait let me hover over it to see what the hotkey is')

This commit is contained in:
Yair Morgenstern 2020-04-16 11:59:11 +03:00
parent 381f61a441
commit 3ba20dca52

View File

@ -16,16 +16,6 @@ import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
private data class UnitIconAndKey (val Icon: Actor, val key: Char = 0.toChar())
class UnitActionButtonOnHoverListener(private val item: Actor, private val keyLabel: Label) : ClickListener() {
override fun enter(event: InputEvent, x: Float, y: Float, pointer: Int, fromActor: Actor?) {
super.enter(event, x, y, pointer, fromActor)
keyLabel.isVisible = true
}
override fun exit(event: InputEvent, x: Float, y: Float, pointer: Int, toActor: Actor?) {
super.exit(event, x, y, pointer, toActor)
keyLabel.isVisible = false
}
}
class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
@ -89,9 +79,8 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
val fontColor = if(unitAction.isCurrentAction) Color.YELLOW else Color.WHITE
actionButton.add(unitAction.title.toLabel(fontColor)).pad(5f)
if (iconAndKey.key != 0.toChar()) {
val keyLabel = "(${iconAndKey.key.toUpperCase()})".toLabel(Color.WHITE).apply { isVisible = false }
val keyLabel = "(${iconAndKey.key.toUpperCase()})".toLabel(Color.WHITE)
actionButton.add(keyLabel)
actionButton.addListener(UnitActionButtonOnHoverListener(actionButton, keyLabel))
}
actionButton.pack()
val action = {