V-Panel/scripts/module_base.gd

53 lines
1 KiB
GDScript3
Raw Permalink Normal View History

extends PanelBase
class_name ModuleBase
signal module_ready
@export var module_title: String = "Module"
var _initialized: bool = false
func _ready() -> void:
# Don't intercept mouse events — DashboardGrid handles drag-and-drop
_set_mouse_ignore(self)
if not _initialized:
_initialize()
func initialize() -> void:
pass
func refresh(data: Dictionary) -> void:
pass
func get_module_title() -> String:
return module_title
func _initialize() -> void:
_initialized = true
initialize()
resized.connect(_update_noise_size)
_update_noise_size()
module_ready.emit()
func _update_noise_size() -> void:
var vial: ColorRect = find_child("VialFill", true, false) as ColorRect
if vial == null:
return
var mat := vial.material as ShaderMaterial
if mat and size.x > 0 and size.y > 0:
mat.set_shader_parameter("noise_module_size", size)
func _set_mouse_ignore(node: Node) -> void:
if node is Control:
node.mouse_filter = Control.MOUSE_FILTER_IGNORE
for child in node.get_children():
_set_mouse_ignore(child)