pleins de trucs
This commit is contained in:
13
scripts/objects/Squeak.lua
Normal file
13
scripts/objects/Squeak.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
---@class Squeak : Event
|
||||
local Squeak, super = Class(Event)
|
||||
|
||||
function Squeak:init(x, y, shape)
|
||||
super.init(self, x, y, shape)
|
||||
end
|
||||
|
||||
function Squeak:onInteract(player, dir)
|
||||
Assets.playSound("squeak")
|
||||
return true
|
||||
end
|
||||
|
||||
return Squeak
|
||||
27
scripts/objects/ToolMenu.lua
Normal file
27
scripts/objects/ToolMenu.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
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!
|
||||
Reference in New Issue
Block a user