38 lines
927 B
GDScript
38 lines
927 B
GDScript
extends Control
|
|
|
|
|
|
@onready var grid: DashboardGrid = %DashboardGrid
|
|
|
|
var _modules: Array = []
|
|
|
|
|
|
func _ready() -> void:
|
|
get_window().mode = Window.MODE_FULLSCREEN
|
|
_set_background()
|
|
_add_modules()
|
|
|
|
|
|
func _set_background() -> void:
|
|
var bg := StyleBoxFlat.new()
|
|
bg.bg_color = Color(0.08, 0.08, 0.12, 1.0)
|
|
add_theme_stylebox_override("panel", bg)
|
|
|
|
|
|
func _add_modules() -> void:
|
|
var cpu := preload("res://panels/cpu/cpu_module.tscn").instantiate()
|
|
grid.place_module(cpu, 0, 0)
|
|
_modules.append(cpu)
|
|
|
|
# Start a timer to refresh all modules every second
|
|
var timer := Timer.new()
|
|
timer.timeout.connect(_refresh_modules)
|
|
timer.autostart = true
|
|
timer.wait_time = 1.0
|
|
add_child(timer)
|
|
|
|
|
|
func _refresh_modules() -> void:
|
|
var data: Dictionary = {}
|
|
for mod in _modules:
|
|
if is_instance_valid(mod) and mod.has_method("refresh"):
|
|
mod.refresh(data)
|