Threads pick within 8 screen px of the line at any zoom

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
tachyonwolf 2026-11-21 09:03:28 -06:00
parent 2241937eb2
commit 3d51c8c8ba

View file

@ -14,6 +14,8 @@ const FAR_ZOOM := 0.22
## roll on a click; their names show as tooltips (CardShield). ## roll on a click; their names show as tooltips (CardShield).
const COMPACT_ZOOM := 0.45 const COMPACT_ZOOM := 0.45
const WORLD_SIZE := 40000.0 const WORLD_SIZE := 40000.0
## How far (screen pixels) from a thread's line a click or hover still picks it.
const PIPE_HIT_RADIUS := 8.0
var main: Main var main: Main
var world: Control var world: Control
@ -203,6 +205,11 @@ func world_mouse() -> Vector2:
return world.get_local_mouse_position() return world.get_local_mouse_position()
## The pipe under the mouse, within PIPE_HIT_RADIUS screen pixels of its line.
func pipe_under_mouse() -> String:
return pipes.pipe_at(world_mouse(), PIPE_HIT_RADIUS / zoom)
func screen_to_world(p: Vector2) -> Vector2: func screen_to_world(p: Vector2) -> Vector2:
return (p - world.position) / zoom return (p - world.position) / zoom
@ -316,7 +323,7 @@ func _gui_input(ev: InputEvent) -> void:
if f is LineEdit or f is TextEdit: if f is LineEdit or f is TextEdit:
f.release_focus() f.release_focus()
if build_left: if build_left:
var key := pipes.pipe_at(world_mouse(), 11.0) if main.mode == Main.Mode.BUILD else "" var key := pipe_under_mouse() if main.mode == Main.Mode.BUILD else ""
if key != "": if key != "":
# The pipe opens in the inspector (Main.open_pipe_options). # The pipe opens in the inspector (Main.open_pipe_options).
main.open_pipe_options(key, mb.global_position) main.open_pipe_options(key, mb.global_position)
@ -359,7 +366,7 @@ func _gui_input(ev: InputEvent) -> void:
MOUSE_BUTTON_RIGHT: MOUSE_BUTTON_RIGHT:
if mb.pressed: if mb.pressed:
# A thread under the mouse, else the empty spread. # A thread under the mouse, else the empty spread.
var key := pipes.pipe_at(world_mouse(), 11.0) var key := pipe_under_mouse()
var list := Actions.thread(main, key) if key != "" else Actions.background(main, world_mouse()) var list := Actions.thread(main, key) if key != "" else Actions.background(main, world_mouse())
if not list.is_empty(): if not list.is_empty():
Actions.popup_at(main, list, mb.global_position) Actions.popup_at(main, list, mb.global_position)
@ -385,7 +392,7 @@ func _gui_input(ev: InputEvent) -> void:
elif _panning: elif _panning:
world.position += mm.relative world.position += mm.relative
elif main.mode == Main.Mode.BUILD: elif main.mode == Main.Mode.BUILD:
pipes.hover_key = pipes.pipe_at(world_mouse(), 11.0) pipes.hover_key = pipe_under_mouse()
mouse_default_cursor_shape = CURSOR_POINTING_HAND if pipes.hover_key != "" else CURSOR_ARROW mouse_default_cursor_shape = CURSOR_POINTING_HAND if pipes.hover_key != "" else CURSOR_ARROW
return return
var pan := ev as InputEventPanGesture var pan := ev as InputEventPanGesture