Fixed key shortcuts in improvement picker screen

This commit is contained in:
Yair Morgenstern 2020-11-11 21:52:48 +02:00
parent dfb3f76157
commit 582cbeb932
3 changed files with 4 additions and 2 deletions

View File

@ -104,7 +104,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
column2.add(mapEditorScreenTable).row()
val modsTable = getTableBlock("Mods", "OtherIcons/Mods")
{ game.setScreen(ModManagementScreen()) }
{ game.setScreen(ModManagementScreen()) }
column2.add(modsTable).row()

View File

@ -79,7 +79,7 @@ class ImprovementPickerScreen(val tileInfo: TileInfo, val onAccept: ()->Unit) :
val pickNow = "Pick now!".toLabel().onClick { accept(improvement) }
if (improvement.shortcutKey != null)
keyPressDispatcher[improvement.shortcutKey] = { accept(improvement) }
keyPressDispatcher[improvement.shortcutKey.toLowerCase()] = { accept(improvement) }
val statIcons = getStatIconsTable(provideResource, removeImprovement)

View File

@ -32,6 +32,7 @@ open class CameraStageBaseScreen : Screen {
protected val tutorialController by lazy { TutorialController(this) }
// An initialized val always turned out to illegally be null...
// Remember to always set LOWER CASE chars as the keys!
var keyPressDispatcher: HashMap<Char, (() -> Unit)>
init {
@ -46,6 +47,7 @@ open class CameraStageBaseScreen : Screen {
stage.addListener(
object : InputListener() {
override fun keyTyped(event: InputEvent?, character: Char): Boolean {
if (character.toLowerCase() !in keyPressDispatcher || hasOpenPopups())
return super.keyTyped(event, character)