refactor(selection): remove prev_click_down, use input.was_action_released (P.3.10)
Behavior identical. lib-core.input dep bump 0.3.0 → 0.4.0. Resolves audit I1 (RTS-Tech-Demo-Audit 2026-05-14).
This commit is contained in:
14
init.lua
14
init.lua
@@ -8,6 +8,9 @@
|
||||
-- action-names (mod_add, mod_toggle). AABB-Hit-Test (last-registered-wins).
|
||||
-- Render: alpha-tinted draw_rect helpers (kein Outline).
|
||||
--
|
||||
-- P.3.10 patch (2026-05-15): prev_click_down workaround removed.
|
||||
-- Uses lib-core.input v0.4.0 was_action_released. Behaviorally identical.
|
||||
--
|
||||
-- DEPRECATED-MVPs siehe Spec §7 + inline-comments unten.
|
||||
-- =====================================================================
|
||||
|
||||
@@ -28,7 +31,6 @@ local press_y = 0
|
||||
local cur_x = 0
|
||||
local cur_y = 0
|
||||
local drag_threshold = 4 -- px
|
||||
local prev_click_down = false -- release-edge detection
|
||||
|
||||
-- Bindings.
|
||||
local click_action = nil
|
||||
@@ -308,15 +310,11 @@ end
|
||||
-- Per-Frame
|
||||
|
||||
function M.update(dt)
|
||||
-- Release-edge detection must sync EVERY frame (even when disabled or unbound)
|
||||
-- so prev_click_down doesn't drift across enable/disable boundaries.
|
||||
local cur_down = (click_action ~= nil) and input.is_action_down(click_action) or false
|
||||
local released = (prev_click_down and not cur_down)
|
||||
prev_click_down = cur_down
|
||||
|
||||
if not enabled_flag then return end
|
||||
if click_action == nil then return end
|
||||
|
||||
local released = input.was_action_released(click_action)
|
||||
|
||||
local mx, my = engine.input.get_mouse_pos()
|
||||
|
||||
if drag_state == "idle" then
|
||||
@@ -380,8 +378,6 @@ function M.render_highlights()
|
||||
end
|
||||
end
|
||||
|
||||
-- DEPRECATED-MVP: was_action_released in lib-core.input (currently tracked internally
|
||||
-- via prev_click_down — promote to input-lib when 2nd consumer needs it)
|
||||
-- DEPRECATED-MVP: pixel-perfect click hit-test (needs sprite-API + opacity-mask)
|
||||
-- DEPRECATED-MVP: register(aabb_fn, z) z-order disambiguator
|
||||
-- DEPRECATED-MVP: on_changed(fn) observer-callback (polling-API sufficient for RTS-MVP)
|
||||
|
||||
Reference in New Issue
Block a user