Added a dynamic layout system where UI elements can be moved about on a tiled grid.

This commit is contained in:
RedNicStone committed 2026-11-09 18:14:52 +01:00
1 parent ea6ba54666
commit 26c29df4ad
34 files changed
+1269

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
extends PanelContainer
signal element_requested(element_type: String)
const CATALOG = preload("res://scripts/layout_catalog.gd")
var _types: Array = []
func _ready() -> void:
_types = CATALOG.ENTRIES.keys()
for element_type in _types:
$Margin/Body/List.add_item(CATALOG.ENTRIES[element_type].title)
$Margin/Body/List.item_selected.connect(_select)
$Margin/Body/List.item_activated.connect(func(_index: int) -> void: _request())
$Margin/Body/Add.pressed.connect(_request)
$Margin/Body/Header/Close.pressed.connect(hide)
$Margin/Body/List.select(0)
_select(0)
func _select(index: int) -> void:
var entry: Dictionary = CATALOG.ENTRIES[_types[index]]
$Margin/Body/Description.text = entry.description
$Margin/Body/Size.text = "%d × %d cells · minimum %d × %d" % [entry.size.x, entry.size.y, entry.minimum.x, entry.minimum.y]
$Margin/Body/Status.text = ""
func _request() -> void:
var indices: PackedInt32Array = $Margin/Body/List.get_selected_items()
if not indices.is_empty():
element_requested.emit(_types[indices[0]])
func show_no_space() -> void:
$Margin/Body/Status.text = "No space available. Move, resize or remove a panel first."