mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Hide hotkeys on devices without keyboard (#3350)
* Hide hotkeys on devices without keyboard * Test for peripheral keyboard
This commit is contained in:
parent
c33793cf81
commit
c338afc7f3
@ -1,5 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen.unit
|
package com.unciv.ui.worldscreen.unit
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
@ -15,7 +17,7 @@ import com.unciv.ui.utils.*
|
|||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
private data class UnitIconAndKey (val Icon: Actor, val key: Char = 0.toChar())
|
private data class UnitIconAndKey(val Icon: Actor, var key: Char = 0.toChar())
|
||||||
|
|
||||||
class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
||||||
|
|
||||||
@ -71,6 +73,11 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() {
|
|||||||
|
|
||||||
private fun getUnitActionButton(unitAction: UnitAction): Button {
|
private fun getUnitActionButton(unitAction: UnitAction): Button {
|
||||||
val iconAndKey = getIconAndKeyForUnitAction(unitAction.title)
|
val iconAndKey = getIconAndKeyForUnitAction(unitAction.title)
|
||||||
|
|
||||||
|
// If peripheral keyboard not detected, hotkeys will not be displayed
|
||||||
|
val keyboardAvailable = Gdx.input.isPeripheralAvailable(Input.Peripheral.HardwareKeyboard)
|
||||||
|
if (!keyboardAvailable){iconAndKey.key = 0.toChar()}
|
||||||
|
|
||||||
val actionButton = Button(CameraStageBaseScreen.skin)
|
val actionButton = Button(CameraStageBaseScreen.skin)
|
||||||
actionButton.add(iconAndKey.Icon).size(20f).pad(5f)
|
actionButton.add(iconAndKey.Icon).size(20f).pad(5f)
|
||||||
val fontColor = if (unitAction.isCurrentAction) Color.YELLOW else Color.WHITE
|
val fontColor = if (unitAction.isCurrentAction) Color.YELLOW else Color.WHITE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user