2026-02-23 18:38:03 -06:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
|
|
var twitcher: TwitcherExtended
|
|
|
|
|
var context: OverlayContext
|
|
|
|
|
var settings: OverlaySettings
|
2026-03-02 02:06:17 -06:00
|
|
|
var main_win: OverlayWindow
|
2026-02-24 03:15:31 -06:00
|
|
|
var _pt_except: Array[Control] = []
|
|
|
|
|
var _pt_mouse: bool = false
|
|
|
|
|
var _current_pt_mask: PackedVector2Array = []
|
2026-02-26 14:36:35 -06:00
|
|
|
var _hull_points: PackedVector2Array = []
|
|
|
|
|
var _debug_draw: DebugDraw
|
2026-02-23 18:38:03 -06:00
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
context = OverlayContext.new()
|
|
|
|
|
context.setup()
|
|
|
|
|
|
|
|
|
|
context.open_db("user://overlay.db")
|
|
|
|
|
context.ensure_tables()
|
|
|
|
|
if FileAccess.file_exists("user://settings.tres"):
|
|
|
|
|
settings = load("user://settings.tres")
|
|
|
|
|
else:
|
|
|
|
|
settings = OverlaySettings.new()
|
|
|
|
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
|
|
|
save_settings()
|
|
|
|
|
|
2026-02-26 14:36:35 -06:00
|
|
|
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)
|
|
|
|
|
|
2026-02-23 18:38:03 -06:00
|
|
|
func save_settings() -> void:
|
|
|
|
|
ResourceSaver.save(settings, "user://settings.tres")
|
2026-02-24 03:15:31 -06:00
|
|
|
|
|
|
|
|
func clear_mouse_passthrough() -> void:
|
|
|
|
|
DisplayServer.window_set_mouse_passthrough([])
|
|
|
|
|
|
|
|
|
|
func _update_mouse_passthrough() -> void:
|
2026-02-27 16:15:46 -06:00
|
|
|
if not _pt_mouse: return
|
2026-02-24 03:15:31 -06:00
|
|
|
var _pt_mask: PackedVector2Array = []
|
|
|
|
|
for node in _pt_except:
|
|
|
|
|
var rect := node.get_global_rect()
|
|
|
|
|
_pt_mask.append_array([
|
|
|
|
|
rect.position,
|
|
|
|
|
Vector2(rect.position.x + rect.size.x, rect.position.y),
|
|
|
|
|
rect.position + rect.size,
|
|
|
|
|
Vector2(rect.position.x, rect.position.y + rect.size.y)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
_current_pt_mask = _pt_mask
|
2026-02-26 14:36:35 -06:00
|
|
|
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
|
2026-02-27 16:15:46 -06:00
|
|
|
if not _pt_mouse: return
|
2026-02-26 14:36:35 -06:00
|
|
|
_update_mouse_passthrough()
|
2026-02-24 03:15:31 -06:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2026-02-26 14:36:35 -06:00
|
|
|
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)
|
|
|
|
|
|
2026-02-24 03:15:31 -06:00
|
|
|
func remove_from_passthrough_exceptioon(control: Control) -> void:
|
|
|
|
|
if _pt_except.has(control):
|
|
|
|
|
_pt_except.erase(control)
|
|
|
|
|
control.item_rect_changed.disconnect(_update_mouse_passthrough)
|
|
|
|
|
|
|
|
|
|
func enable_mouse_passthrough() -> void:
|
|
|
|
|
if _pt_mouse:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
_pt_mouse = true
|
|
|
|
|
_update_mouse_passthrough()
|
|
|
|
|
|
|
|
|
|
func disable_mouse_passthrough() -> void:
|
|
|
|
|
if not _pt_mouse:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
_pt_mouse = false
|
|
|
|
|
clear_mouse_passthrough()
|
2026-02-26 14:36:35 -06:00
|
|
|
|
|
|
|
|
func get_exception_points() -> PackedVector2Array:
|
|
|
|
|
return _current_pt_mask
|
|
|
|
|
|
|
|
|
|
func get_polygon_points() -> PackedVector2Array:
|
|
|
|
|
return _hull_points
|