Let the speed fader have the click it is under

Clicking the fader did nothing on a desktop: it fired the guns instead.
Unhandled input reaches the last nodes in the tree first, and the fader's
mouse handling lived in GameController - the script on Main, the ROOT, so
it was served last of all. MouseCombatController is a child of it and marks
every left press handled to fire, so the press never arrived.

The fader asks for its own mouse events now, from the UI layer, which sits
after the combat controllers: the control the pointer is actually on gets
the press ahead of the guns behind it. The handlers themselves are the same
wrappers #118 wrote.

The test for #118 could not see any of this - it handed the event straight
to Main._unhandled_input, which is precisely the delivery the real game
never makes, so it passed against the bug it was written for. It pushes
through the viewport now, with mouse aiming on, and checks the guns stay
quiet. Confirmed it fails without the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QR2Mdk42ghEpeyXPe4UFyn
This commit is contained in:
Loïc Wisniewski 2026-09-12 19:06:14 +02:00
commit a43fae5e28
3 changed files with 78 additions and 18 deletions

View file

@ -383,14 +383,14 @@ func _unhandled_input(event: InputEvent) -> void:
_handle_key(event)
elif event is InputEventMouseMotion:
_note_keyboard()
if speed_fader != null:
speed_fader.handle_mouse_motion(event)
elif event is InputEventMouseButton:
_note_keyboard()
# #118: the fader gets first refusal, so dragging the boost does not
# also pan or zoom the world behind it.
if speed_fader != null and speed_fader.handle_mouse_button(event):
return
# The speed fader used to be driven from here, and could not work:
# MouseCombatController is dispatched before this node (it is a
# child, and this is the root) and marks every left press handled to
# fire the guns, so the press never arrived. It listens for its own
# mouse events now - see SpeedFader._unhandled_input - and claims
# them from the UI layer, ahead of the combat controllers.
if not event.pressed:
return
# Wheel zoom, the desktop equivalent of the pinch.