27 lines
1.6 KiB
Lua
27 lines
1.6 KiB
Lua
local outer = Component(FixedSizing(640, 480)) -- The root should be a fixed size.
|
|
outer:setLayout(VerticalLayout({ gap = 0, align = "center" })) -- Center it vertically!
|
|
local inner = Component(FillSizing(), FitSizing()) -- Stretch horizontally, fit to content vertically
|
|
inner:setLayout(HorizontalLayout({ gap = 0, align = "center" })) -- Center it horizontally!
|
|
-- anything we add to inner will be centered horizontally
|
|
local box = BoxComponent(FitSizing())
|
|
local menu = BasicMenuComponent(FitSizing())
|
|
menu:setLayout(VerticalLayout({ gap = 0, align = "start" }))
|
|
menu:addChild(SoulMenuItemComponent(Text("Option 1"), function() print("Option 1 was selected!") end))
|
|
menu:addChild(SoulMenuItemComponent(Text("Option 2"), function() print("Option 2 was selected!") end))
|
|
menu:addChild(SoulMenuItemComponent(Text("Option 3"), function() print("Option 3 was selected!") end))
|
|
menu:addChild(SoulMenuItemComponent(Text("Option 4"), function() print("Option 4 was selected!") end))
|
|
menu:addChild(SoulMenuItemComponent(Text("Option 5"), function() print("Option 5 was selected!") end))
|
|
|
|
menu:setFocused()
|
|
menu:setCancelCallback(function()
|
|
menu:close()
|
|
Game.world:closeMenu()
|
|
end)
|
|
|
|
menu:setFocused()
|
|
inner:addChild(menu)
|
|
inner:addChild(box)
|
|
outer:addChild(inner)
|
|
|
|
|
|
return outer-- Add the inner component to the outer component! |