From 64f718a1cd694be0952fd3700636d81ba05d30f0 Mon Sep 17 00:00:00 2001 From: Physcik Date: Sat, 7 Feb 2026 23:20:48 +0500 Subject: Dynamic menus --- engine/Dynamic/Descriptors/UIElement.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engine/Dynamic/Descriptors/UIElement.go') diff --git a/engine/Dynamic/Descriptors/UIElement.go b/engine/Dynamic/Descriptors/UIElement.go index 9b88ab3..1b19ba2 100644 --- a/engine/Dynamic/Descriptors/UIElement.go +++ b/engine/Dynamic/Descriptors/UIElement.go @@ -22,11 +22,13 @@ type UIElementDescriptor struct { Spacing float32 } +// We have to initialize the map so that we avoid the circular reference in the recursive parsing func InitUIParser() { typeParsers = map[string]func(*UIElementDescriptor) ui.UIElement { ui.VoidTypeName: parseAsVoid, ui.LabelTypeName: parseAsLabel, ui.GridRowTypeName: parseAsGridRow, + ui.GridColumnTypeName: parseAsGridColumn, } } @@ -82,3 +84,21 @@ func parseAsGridRow(base *UIElementDescriptor) ui.UIElement { } return &outp } + +func parseAsGridColumn(base *UIElementDescriptor) ui.UIElement { + var outp = ui.GridColumn { + Weight: base.Weight, + Spacing: base.Spacing, + Style: base.Style.Parse(), + Objects: make([]ui.UIElement, 0, len(base.Children)), + } + for _, v := range base.Children { + var child, parseErr = v.Parse() + if parseErr != nil { + rl.TraceLog(rl.LogWarning, "Failed to parse a parent element of a grid column: %v", parseErr.Error()) + continue + } + outp.Objects = append(outp.Objects, child) + } + return &outp +} -- cgit v1.3