From fb37c05708ea7ddec2777f3e9ceef0896115e502 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 14 Mar 2025 08:37:21 +0800 Subject: feat(i18n): press Ctrl+L or Command+L to switch languages --- logic/controller.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'logic/controller.lua') 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) -- cgit v1.2.3