Updated Globals

Updated logic to handle using a convex_hull() for the points, instead of
individiual boxes.
Added Debug toggle.
This commit is contained in:
Mario Steele 2026-02-26 14:36:35 -06:00
parent e055de131f
commit 015a601be6

View file

@ -6,6 +6,8 @@ var settings: OverlaySettings
var _pt_except: Array[Control] = []
var _pt_mouse: bool = false
var _current_pt_mask: PackedVector2Array = []
var _hull_points: PackedVector2Array = []
var _debug_draw: DebugDraw
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@ -22,10 +24,18 @@ func _ready() -> void:
func _exit_tree() -> void:
save_settings()
func _input(_event: InputEvent) -> void:
if Input.is_action_just_pressed("debug_draw"):
if _debug_draw:
_debug_draw.queue_free()
_debug_draw = null
else:
_debug_draw = DebugDraw.new()
add_child(_debug_draw)
func save_settings() -> void:
ResourceSaver.save(settings, "user://settings.tres")
func clear_mouse_passthrough() -> void:
DisplayServer.window_set_mouse_passthrough([])
@ -40,18 +50,31 @@ func _update_mouse_passthrough() -> void:
Vector2(rect.position.x, rect.position.y + rect.size.y)
])
if _pt_mask == _current_pt_mask:
print("No Changed made, returning.")
return
_current_pt_mask = _pt_mask
DisplayServer.window_set_mouse_passthrough(_current_pt_mask)
var hull_points := Geometry2D.convex_hull(_pt_mask)
_hull_points = hull_points
DisplayServer.window_set_mouse_passthrough(hull_points)
func _process(_d: float) -> void:
if _pt_except.size() == 0: return
_update_mouse_passthrough()
func add_to_passthrough_exception(control: Control) -> void:
if not _pt_except.has(control):
_pt_except.append(control)
control.item_rect_changed.connect(_update_mouse_passthrough)
func add_children_to_passthrough_exception(control: Control, ignore: Array[Control] = []) -> void:
if not _pt_except.has(control):
_pt_except.append(control)
for child in control.get_children():
if child in ignore: continue
if child.get_child_count() > 0:
add_children_to_passthrough_exception(child, ignore)
else:
_pt_except.append(child)
child.item_rect_changed.connect(_update_mouse_passthrough)
func remove_from_passthrough_exceptioon(control: Control) -> void:
if _pt_except.has(control):
_pt_except.erase(control)
@ -70,3 +93,9 @@ func disable_mouse_passthrough() -> void:
_pt_mouse = false
clear_mouse_passthrough()
func get_exception_points() -> PackedVector2Array:
return _current_pt_mask
func get_polygon_points() -> PackedVector2Array:
return _hull_points