diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-14 08:37:21 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-14 08:37:21 +0800 |
| commit | fb37c05708ea7ddec2777f3e9ceef0896115e502 (patch) | |
| tree | b9da90a65b033337c209dc92543c9c13e55270be /logic/controller.lua | |
| parent | c538f03cdb2242f227d741cfb2c6753fb9d15473 (diff) | |
feat(i18n): press Ctrl+L or Command+L to switch languages
Diffstat (limited to 'logic/controller.lua')
| -rw-r--r-- | logic/controller.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/logic/controller.lua b/logic/controller.lua index eb9cb20..0159ebd 100644 --- a/logic/controller.lua +++ b/logic/controller.lua @@ -2,6 +2,11 @@ require "data.directions" local controller = {} +function controller.ctrlKeyPressed() + local keydown = love.keyboard.isDown + return keydown("lgui") or keydown("rgui") or keydown("lctrl") or keydown("rctrl") +end + local function playerPressKeysToArrangeHearts(key) -- rearrange heart sequence with number keys local i = tonumber(key) @@ -54,6 +59,14 @@ local function playerClickMouseToPunch(x, y) G.player:punch({ x = x, y = y}) end +-- settings + +local function switchLanguageSetting(key) + if key == "l" and controller.ctrlKeyPressed() then + config.lang = config.lang == "en" and "zh" or "en" + end +end + -- entry functions -- controller that needs constant press check @@ -65,6 +78,7 @@ end -- controller that requires one key press function controller.keypressed(key) playerPressKeysToArrangeHearts(key) + switchLanguageSetting(key) end function controller.mousereleased(x, y, button) |
