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:
parent
93bfe62e76
commit
a43fae5e28
3 changed files with 78 additions and 18 deletions
|
|
@ -101,6 +101,28 @@ func handle_mouse_motion(event: InputEventMouseMotion) -> bool:
|
|||
return true
|
||||
|
||||
|
||||
# ...and listening for those events HERE rather than being handed them by
|
||||
# GameController, which is what #118 did.
|
||||
#
|
||||
# Unhandled input reaches the last nodes in the tree first, and Main - where
|
||||
# that dispatch lives - is the root, so it is served last of all.
|
||||
# MouseCombatController is a child of it and claims every left press to fire
|
||||
# the fleet's guns, which meant a click on the fader shot at the fader
|
||||
# instead of taking hold of it: the knob never moved on a desktop. The UI
|
||||
# layer sits after the combat controllers, so asking for the event here puts
|
||||
# the control the player is actually pointing at ahead of the guns behind it.
|
||||
#
|
||||
# Touch still comes through GameController: nothing competes for a finger,
|
||||
# and the joystick/fire stick ordering it arbitrates is real.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if handle_mouse_button(event):
|
||||
get_viewport().set_input_as_handled()
|
||||
elif event is InputEventMouseMotion:
|
||||
if handle_mouse_motion(event):
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func handle_touch(event: InputEventScreenTouch) -> bool:
|
||||
return _press(event.pressed, event.position, event.index)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue