The console key should be bindable? (#10952)

This commit is contained in:
SomeTroglodyte 2024-01-19 11:07:15 +01:00 committed by GitHub
parent 940cda3009
commit 4e67d9535f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -8,6 +8,12 @@ import com.unciv.models.stats.Stat
private val unCamelCaseRegex = Regex("([A-Z])([A-Z])([a-z])|([a-z])([A-Z])")
private fun unCamelCase(name: String) = unCamelCaseRegex.replace(name, """$1$4 $2$3$5""")
/**
* This is the database of supported "bindable" keyboard shortcuts.
*
* Note a label is automatically generated from the name by inserting spaces before each uppercase letter (except the initial one),
* and translation keys are automatically generated for all labels. This also works for [KeyboardBinding.Category].
*/
enum class KeyboardBinding(
val category: Category,
label: String? = null,
@ -35,6 +41,7 @@ enum class KeyboardBinding(
NextTurnAlternate(Category.WorldScreen, KeyCharAndCode.SPACE),
EmpireOverview(Category.WorldScreen),
MusicPlayer(Category.WorldScreen, KeyCharAndCode.ctrl('m')),
DeveloperConsole(Category.WorldScreen, '`'),
/*
* These try to be faithful to default Civ5 key bindings as found in several places online

View File

@ -192,7 +192,7 @@ class WorldScreen(
globalShortcuts.add(KeyCharAndCode.BACK) { backButtonAndESCHandler() }
globalShortcuts.add('`') {
globalShortcuts.add(KeyboardBinding.DeveloperConsole) {
// No cheating unless you're by yourself
if (gameInfo.civilizations.count { it.isHuman() } > 1) return@add
val consolePopup = DevConsolePopup(this)