input remapping + mouse control
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-04-02 18:19:25 +02:00
parent 6e1cf1db3e
commit 7697b35336
24 changed files with 178 additions and 45 deletions

View File

@@ -107,9 +107,9 @@ function AudioTestWindow.update()
AudioTestWindow.menuitems = AudioTestWindow.generate_menuitems(
AudioTestWindow.list_func, AudioTestWindow.index_func
)
elseif Input.menu_confirm() then
elseif Input.select() then
AudioTestWindow.menuitems[AudioTestWindow.index_menu].decision()
elseif Input.menu_back() then
elseif Input.back() then
AudioTestWindow.back()
end
end

View File

@@ -65,7 +65,7 @@ end
--- Updates configuration window logic.
--- @within ConfigurationWindow
function ConfigurationWindow.update()
if Input.menu_back() then
if Input.back() then
GameWindow.set_state("menu")
return
end
@@ -94,7 +94,7 @@ function ConfigurationWindow.update()
control.set(new_value)
end
elseif control.type == "action_item" then
if Input.menu_confirm() then
if Input.select() then
control.action()
end
end

View File

@@ -26,7 +26,7 @@ end
--- @within ContinuedWindow
function ContinuedWindow.update()
ContinuedWindow.timer = ContinuedWindow.timer - 1
if ContinuedWindow.timer <= 0 or Input.select() or Input.menu_confirm() then
if ContinuedWindow.timer <= 0 or Input.select() or Input.select() then
Window.set_current("menu")
MenuWindow.refresh_menu_items()
end

View File

@@ -52,7 +52,7 @@ function EndWindow.update()
end
end
if Input.menu_confirm() then
if Input.select() then
Audio.sfx_select()
if Context._end.selection == 1 then
Context._end.state = "ending"
@@ -69,7 +69,7 @@ function EndWindow.update()
end
end
elseif Context._end.state == "ending" then
if Input.menu_confirm() then
if Input.select() then
Window.set_current("menu")
MenuWindow.refresh_menu_items()
end

View File

@@ -38,7 +38,7 @@ end
--- @within GameWindow
function GameWindow.update()
Focus.update()
if Input.menu_back() then
if Input.back() then
Window.set_current("menu")
MenuWindow.refresh_menu_items()
return
@@ -60,7 +60,7 @@ function GameWindow.update()
_selected_decision_index = 1
end
local new_selected_decision_index = Decision.update(
local new_selected_decision_index, mouse_confirmed = Decision.update(
_available_decisions,
_selected_decision_index
)
@@ -69,7 +69,7 @@ function GameWindow.update()
_selected_decision_index = new_selected_decision_index
end
if Input.select() then
if Input.select() or mouse_confirmed then
local selected_decision = _available_decisions[_selected_decision_index]
if selected_decision and selected_decision.handle then
Audio.sfx_select()

View File

@@ -31,7 +31,7 @@ function BriefIntroWindow.update()
lines = lines + 1
end
if BriefIntroWindow.y < -lines * 8 or Input.select() or Input.menu_confirm() then
if BriefIntroWindow.y < -lines * 8 or Input.select() or Input.select() then
Window.set_current("menu")
end
end

View File

@@ -30,7 +30,7 @@ end
--- @within TitleIntroWindow
function TitleIntroWindow.update()
TitleIntroWindow.timer = TitleIntroWindow.timer - 1
if TitleIntroWindow.timer <= 0 or Input.select() or Input.menu_confirm() then
if TitleIntroWindow.timer <= 0 or Input.select() or Input.select() then
Window.set_current("intro_ttg")
end
end

View File

@@ -28,12 +28,12 @@ function TTGIntroWindow.update()
end
-- Count menu_back presses during the intro
if Input.menu_back() then
if Input.back() then
TTGIntroWindow.space_count = TTGIntroWindow.space_count + 1
end
TTGIntroWindow.timer = TTGIntroWindow.timer - 1
if TTGIntroWindow.timer <= 0 or Input.menu_confirm() then
if TTGIntroWindow.timer <= 0 or Input.select() then
-- Evaluate exactly 3 presses at the end of the intro
if TTGIntroWindow.space_count == 3 then
Context.test_mode = true

View File

@@ -1,5 +1,6 @@
--- @section MenuWindow
local _menu_items = {}
local _click_timer = 0
--- Draws the menu window.
--- @within MenuWindow
@@ -22,9 +23,28 @@ end
--- Updates the menu window logic.
--- @within MenuWindow
function MenuWindow.update()
Context.current_menu_item = UI.update_menu(_menu_items, Context.current_menu_item)
local menu_h = #_menu_items * 10
local y = 10 + (Config.screen.height - 10 - 10 - menu_h) / 2
if Input.menu_confirm() then
if _click_timer > 0 then
_click_timer = _click_timer - Context.delta_time
if _click_timer <= 0 then
_click_timer = 0
local selected_item = _menu_items[Context.current_menu_item]
if selected_item and selected_item.decision then
selected_item.decision()
end
end
return
end
local new_item, mouse_confirmed = UI.update_menu(_menu_items, Context.current_menu_item, 0, y, true)
Context.current_menu_item = new_item
if mouse_confirmed then
Audio.sfx_select()
_click_timer = 0.5
elseif Input.select() then
local selected_item = _menu_items[Context.current_menu_item]
if selected_item and selected_item.decision then
Audio.sfx_select()
@@ -115,4 +135,5 @@ function MenuWindow.refresh_menu_items()
table.insert(_menu_items, {label = "Exit", decision = MenuWindow.exit})
Context.current_menu_item = 1
_click_timer = 0
end

View File

@@ -355,6 +355,17 @@ function MinigameDDRWindow.update()
right = Input.right()
}
if Mouse.clicked() then
local mx = Mouse.x()
local my = Mouse.y()
for _, target in ipairs(mg.target_arrows) do
if mx >= target.x and mx < target.x + mg.arrow_size and
my >= mg.target_y and my < mg.target_y + mg.arrow_size then
input_map[target.dir] = true
end
end
end
for dir, pressed in pairs(input_map) do
if pressed and mg.input_cooldowns[dir] == 0 then
mg.input_cooldowns[dir] = mg.input_cooldown_duration

View File

@@ -83,7 +83,14 @@ function MinigameButtonMashWindow.update()
return
end
if Input.select() then
local mouse_on_button = false
if Mouse.clicked() then
local dx = Mouse.x() - mg.button_x
local dy = Mouse.y() - mg.button_y
mouse_on_button = (dx * dx + dy * dy) <= (mg.button_size * mg.button_size)
end
if Input.select() or mouse_on_button then
Audio.sfx_drum_high()
mg.bar_fill = mg.bar_fill + mg.fill_per_press

View File

@@ -95,7 +95,14 @@ function MinigameRhythmWindow.update()
if mg.press_cooldown > 0 then
mg.press_cooldown = mg.press_cooldown - 1
end
if Input.select() and mg.press_cooldown == 0 then
local mouse_on_button = false
if Mouse.clicked() then
local dx = Mouse.x() - mg.button_x
local dy = Mouse.y() - mg.button_y
mouse_on_button = (dx * dx + dy * dy) <= (mg.button_size * mg.button_size)
end
if (Input.select() or mouse_on_button) and mg.press_cooldown == 0 then
mg.button_pressed_timer = mg.button_press_duration
mg.press_cooldown = mg.press_cooldown_duration
local target_left = mg.target_center - (mg.target_width / 2)

View File

@@ -28,7 +28,7 @@ end
--- @within PopupWindow
function PopupWindow.update()
if Context.popup.show then
if Input.menu_confirm() or Input.menu_back() then
if Input.select() or Input.back() then
PopupWindow.hide()
end
end